fix(agent-tools): inherit parent RunConfig when agent-as-tool is invoked#2463
Conversation
|
Added a follow-up regression test in commit b8741b1 to explicitly cover inherited tracing privacy config on agent-as-tool runs:\n\n- \n\nThis verifies that on the parent RunConfig is preserved for the nested run when does not pass an explicit run_config. |
|
Correction for formatting: added follow-up regression test in commit b8741b1 named test_agent_as_tool_inherits_trace_include_sensitive_data_setting. It verifies that trace_include_sensitive_data=False on the parent RunConfig is preserved for nested agent-as-tool runs when no explicit run_config is passed to as_tool. |
|
@codex review again |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Implemented this suggestion in commit 0d6f225. Change made:
Local verification:
|
Summary
This fixes a bug where an agent used as a tool could ignore the parent run's
RunConfig(notably custommodel_provider) unless a separaterun_configwas explicitly passed toAgent.as_tool(...).What changed
run_configtoToolContextso tool invocations can carry run-level configuration metadata.configintoToolContext.from_agent_context(...).Agent.as_tool(...):run_configis explicitly provided, keep using it;run_configfrom the parentToolContextwhen available.run_configwhenas_tool(run_config=None);run_configoverriding parent context;RunConfig.Why this is safe
run_configbehavior remains unchanged.ToolContext.run_configdefaults toNone).Validation
uv run --with ruff ruff check src/agents/agent.py src/agents/tool_context.py src/agents/run_internal/tool_execution.py tests/test_agent_as_tool.py tests/test_tool_context.py tests/test_run_step_execution.pyuv run --with pytest --with socksio pytest -q tests/test_tool_context.py tests/test_agent_as_tool.py tests/test_run_step_execution.pyuv run --with mypy --with socksio mypy src/agents/agent.py src/agents/tool_context.py src/agents/run_internal/tool_execution.py tests/test_tool_context.py tests/test_agent_as_tool.py tests/test_run_step_execution.py