Skip to content

Add run configuration inheritance for agent-as-tool workflows #1006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DanielHashmi
Copy link
Contributor

Problem:
When using the "agents as tools" pattern, tool-agents create their own execution context but don't inherit the parent's run_config.

This creates two problems:
Tool-agents can't access the parent's global model configuration
If tool-agents don't have their own model field set and the parent's run_config.model is unavailable, model resolution fails entirely, causing the orchestrator to fail when calling the tool

Solution:
Modified the agent-as-tool execution to properly handle run_config inheritance while ensuring robust model resolution. This prevents execution failures when tool-agents lack explicit model configuration.

Changes

1. traces.py

  • Added _run_config attribute to both NoOpTrace and TraceImpl classes
  • Added TYPE_CHECKING import for RunConfig type annotation
  • Enables storing run configuration in trace context for cross-agent access

2. run.py

  • Enhanced trace context management to store run configuration
  • Implements two-tier storage: metadata dictionary (preferred) or _run_config attribute (fallback)
  • Ensures sub-agents can access original run configuration during execution

3. agent.py

  • Added get_current_trace import from tracing module
  • Enhanced as_tool() method to retrieve and inherit run configuration from trace context
  • Passes inherited configuration to Runner.run() for consistent behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant