Skip to content

feat: #2247 add RunResult tool_context accessor for agent tools#2575

Merged
seratch merged 1 commit intomainfrom
feat/run-result-tool-context
Mar 1, 2026
Merged

feat: #2247 add RunResult tool_context accessor for agent tools#2575
seratch merged 1 commit intomainfrom
feat/run-result-tool-context

Conversation

@seratch
Copy link
Member

@seratch seratch commented Mar 1, 2026

This pull request adds a typed RunResult.tool_context convenience accessor for nested agent-tool runs so custom_output_extractor implementations can inspect ToolContext metadata without a cast. The change keeps the existing RunResult and RunResultStreaming constructor shapes intact by adding the accessor on the shared RunResultBase, which keeps the release risk low while improving mypy ergonomics for agent-as-tool integrations.

It also updates the agent-as-tool tests to cover both non-streaming and streaming extractor access to tool_context, and documents the new extractor pattern in docs/tools.md. Behavior is unchanged for normal runs: tool_context is None unless the run was started through Agent.as_tool(...).

Resolves #2247

@seratch seratch added this to the 0.10.x milestone Mar 1, 2026
@github-actions github-actions bot added enhancement New feature or request feature:core labels Mar 1, 2026
@seratch seratch merged commit bb14973 into main Mar 1, 2026
9 checks passed
@seratch seratch deleted the feat/run-result-tool-context branch March 1, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access to call_id in custom_output_extractor for agent-as-tool pattern

1 participant