feat(openai-temporal): render hosted/server-side tool calls in TemporalStreamingModel#442
Merged
Merged
Conversation
5d5a0e8 to
b5cbe37
Compare
ef09c56 to
99895bb
Compare
b5cbe37 to
e089205
Compare
…alStreamingModel web_search, file_search, code_interpreter, image generation, and server-side mcp calls run inside the Responses API: they never become function_call items and the SDK RunHooks never fire, so the streaming model dropped them entirely (no UI event). Surface each completed hosted-tool output item as a ToolRequestContent + ToolResponseContent pair, mirroring how function_call tools render. This upstreams the hosted-tool half of the golden agent's vendored RichToolStreamingModel so that agent can stop vendoring. The reasoning double-render fix it also carried is already handled upstream (a533598), so only the hosted-tool handling is ported here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
99895bb to
ec0df6c
Compare
…ration hosted tools Add _hosted_tool_request branches for computer_call and local_shell_call (both carry an action object) and surface a compact image reference for image_generation_call results, so these hosted tools show real detail in the trace instead of empty args. Harden the web_search test to use the real ResponseFunctionWebSearch/ActionSearch SDK types (the action field exists on the SDK type) and add coverage for the new branches. Addresses Greptile review feedback on #442. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #436. Renders Responses-API hosted/server-side tool calls (
web_search,file_search,code_interpreter, image generation, server-sidemcp,computer_call,local_shell_call) asToolRequestContent+ToolResponseContentpairs inTemporalStreamingModel.These tools execute inside the Responses API, so they never become
function_callitems and the SDKRunHooks(on_tool_start/on_tool_end) never fire for them. Previously they produced no UI event at all. Each completed hosted-tool output item is now surfaced as a request/response pair, mirroring howfunction_calltools already render.This upstreams the hosted-tool half of
golden_agent's vendoredRichToolStreamingModelso that agent can stop vendoring (its "Phase 4"). The reasoning double-render fix the vendored model also carried already landed upstream (a5335983, fixed at the streaming-layer root cause), so only hosted-tool handling is ported here.Changes
_HOSTED_TOOL_TYPES,_coerce_args,_hosted_tool_request,_hosted_tool_result._post_tool_messagemethod (one-shot full message, no deltas).elif item.type in _HOSTED_TOOL_TYPESbranch in theResponseOutputItemDoneEventhandler.function_call, reasoning, and text handling are unchanged.Test plan
tests/test_hosted_tools.py) covering the extraction helpers.openai_agentsplugin suite (45 tests) stays green; ruff clean.web_search/ server-sidemcp) renders a request+response pair in the UI.Note: base is
declan-scale/init-templates-codex(#436 head) — review/merge #436 first.🤖 Generated with Claude Code
Greptile Summary
This PR adds rendering of Responses-API hosted/server-side tool calls (
web_search,file_search,code_interpreter,image_generation,mcp,computer_call,local_shell_call) asToolRequestContent+ToolResponseContentpairs inTemporalStreamingModel. Previously, these tools executed silently inside the API with no UI event._HOSTED_TOOL_TYPES,_coerce_args,_hosted_tool_request,_hosted_tool_result) extract call ID, display name, args, and a capped result string from completed hosted-tool SDK items._post_tool_messageone-shot method posts both halves of the request/response pair using the samestreaming_task_message_contextSTART→FULL pattern used by the existingfunction_callhandler.elifbranch in theResponseOutputItemDoneEventhandler triggers the new path without touching any existingfunction_call, reasoning, or text handling.Confidence Score: 5/5
Purely additive change with no modifications to existing function_call, reasoning, or text paths; safe to merge.
All new code follows the established START→FULL streaming pattern used by the function_call handler. The elif branch is correctly scoped, helper functions are well-tested with real SDK types, and the hosted-tool items naturally flow through the existing final response processing via ResponseCompletedEvent. No changes to existing streaming paths.
No files require special attention.
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant API as Responses API participant TSM as TemporalStreamingModel participant PM as _post_tool_message participant SC as StreamingTaskMessageContext participant UI as UI / Redis Stream API->>TSM: ResponseOutputItemDoneEvent (hosted tool) TSM->>TSM: _hosted_tool_request(item) → call_id, name, args TSM->>TSM: _hosted_tool_result(item) → result string TSM->>PM: _post_tool_message(ToolRequestContent) PM->>SC: async with streaming_task_message_context(initial_content) SC->>UI: START event (ToolRequestContent) PM->>SC: stream_update(StreamTaskMessageFull) SC->>UI: FULL event (ToolRequestContent) SC-->>PM: __aexit__ → close() early-returns (already closed) TSM->>PM: _post_tool_message(ToolResponseContent) PM->>SC: async with streaming_task_message_context(initial_content) SC->>UI: START event (ToolResponseContent) PM->>SC: stream_update(StreamTaskMessageFull) SC->>UI: FULL event (ToolResponseContent) SC-->>PM: __aexit__ → close() early-returns (already closed)%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant API as Responses API participant TSM as TemporalStreamingModel participant PM as _post_tool_message participant SC as StreamingTaskMessageContext participant UI as UI / Redis Stream API->>TSM: ResponseOutputItemDoneEvent (hosted tool) TSM->>TSM: _hosted_tool_request(item) → call_id, name, args TSM->>TSM: _hosted_tool_result(item) → result string TSM->>PM: _post_tool_message(ToolRequestContent) PM->>SC: async with streaming_task_message_context(initial_content) SC->>UI: START event (ToolRequestContent) PM->>SC: stream_update(StreamTaskMessageFull) SC->>UI: FULL event (ToolRequestContent) SC-->>PM: __aexit__ → close() early-returns (already closed) TSM->>PM: _post_tool_message(ToolResponseContent) PM->>SC: async with streaming_task_message_context(initial_content) SC->>UI: START event (ToolResponseContent) PM->>SC: stream_update(StreamTaskMessageFull) SC->>UI: FULL event (ToolResponseContent) SC-->>PM: __aexit__ → close() early-returns (already closed)Reviews (4): Last reviewed commit: "fix(openai-temporal): render args for co..." | Re-trigger Greptile