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 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,22 @@ def as_tool(
description_override=tool_description or "",
)
async def run_agent(context: RunContextWrapper, input: str) -> str:
from .run import Runner
from .run import Runner, get_current_run_config

# Get the current run_config from context if available
run_config = None
current_run_config = get_current_run_config()
if current_run_config and current_run_config.pass_run_config_to_sub_agents:
run_config = current_run_config

output = await Runner.run(
starting_agent=self,
input=input,
context=context.context,
run_config=run_config,
)
if custom_output_extractor:
return await custom_output_extractor(output)

return ItemHelpers.text_message_outputs(output.new_items)

return run_agent
Expand Down
Loading