Repository navigation
fix(responses): execute hosted web_search and accept web_search_call replay - #45
Merged
Merged
Conversation
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.
Fixes two Grok Build session breakers in the Responses frontend (
/v1/responses). Closes #43.Bug 1: hosted
web_searchdeclaration was droppedGrok Build (backend search enabled, the default) declares
{"type":"web_search"}; the proxy dropped it, so the model never had a search tool and Grok Build's server-side search was dead at this gateway.Fix: the declaration converts to the same upstream
web_searchfunction the Anthropic frontend offers (websearch::upstream_function). When the model calls it, the gateway executes Cline/search/websearchwith the active credential (search_web, same client/route/never-rotates-pool rules as the Anthropic server-tool loop) and streams:response.web_search_call.in_progressper call;response.output_item.donecarrying the fullweb_search_callitem (id,status,action.searchwith query + source URLs) — also recorded for terminal reconstruction, so Grok Build can replay it next turn;tool_calls+role=toolresults). Pure server-tool rounds continue the same downstream stream; mixed rounds (server + client tools) end the stream after executing the searches so the client can run its own tools.A per-request budget (from the declaration's
max_uses, clamped toMAX_WEB_SEARCH_USES_PER_REQUEST, default 5) bounds searches; exceeded calls surface asmax_uses_exceededfailed results, never silently truncated. Continuations reusesend_chat, so effective-429 failover and no-replay-after-commit apply per round; a failed continuation is terminal (semantic output already streamed).Bug 2: replayed
web_search_callinput items hard-failed the sessionGrok Build replays
response.completed.outputitems as the next turn's input. Aweb_search_callitem hit theunsupported item type400 and permanently broke the session (every later request failed).Fix:
web_search_callitems rebuild the assistant(tool_calls)/role=toolmessage pair from the item's ownaction.search.queryandaction.sourcesURLs — nothing invented (a failed call replays as its failure; its sources list is empty). The item's own id is reused, so thetool_calls↔tool_call_idchain stays valid.Unchanged
x_search,code_interpreter, MCP, …) remain dropped, never forwarded, never faked.web_searchesin the request summary).Tests
New coverage: hosted
web_searchconversion (+max_usesclamping),web_search_callreplay rebuild (unit + integration), hosted-tool drop for non-web_search types, and a full streaming server-round integration test (model callsweb_search→ gateway executes → continuation generation runs with the grounding → client seesweb_search_callitems and the grounded answer, never afunction_callfor the server tool). Existing tool/replay/429 tests unchanged and green.Gates: fmt OK, check OK, clippy
-D warningsOK, 309 tests debug OK, 309 tests release OK.Docs
README (web_search support in the Grok Build section) and
docs/DEVELOPMENT_STATE.mdupdated.