fix(xai): OAuth Responses native web_search, incomplete guard, grok-composer 262k context - #44341
fix(xai): OAuth Responses native web_search, incomplete guard, grok-composer 262k context#44341XVVH wants to merge 1 commit into
Conversation
…omposer context
- model_metadata: grok-composer-2.5-fast → 262144 (OAuth slug not in /v1/models)
- codex transport: inject native {"type":"web_search"} for is_xai_responses;
drop client web_search to avoid duplicate-name 400s
- codex adapter: do not treat in-progress server-side *_call items as incomplete
- tests: adapter, transport build_kwargs, model_metadata, oauth recovery
|
Verification review — Reviewed the full diff (7 files, +310/-2) for xAI OAuth Responses native web_search support. What I verified:
Clean implementation. The inline comments thoroughly document the exact failure mode (incomplete status not reconciled by xAI's /v1/responses surface) and the architectural tradeoff (native search bypasses Hermes tool-trace). |
✅ Code Review — CleanReviewed the full diff across 5 files ( What I verified:
The No issues found. LGTM. |
…tx to 200k Salvage corrections on top of @XVVH's #44341: - Make native web_search injection a 1:1 swap for an already-present client web_search function, NOT an additive grant. The original unconditionally appended {"type":"web_search"} on every is_xai_responses turn with any tools, force-enabling Grok server-side search even when the user never enabled the web toolset (bypassing Hermes web-provider config + tool-trace plumbing). Now gated on a client web_search actually being present. - Reconcile grok-composer context to 200000 (merged in #47908) rather than 262144; 200k is xAI's published usable context window for Composer 2.5, 262144 is the /v1/responses input+output budget. - Update tests to match scoped behavior + add a no-web-toolset guard test. - AUTHOR_MAP entry for #44341 salvage. Incomplete-guard (server-side *_call items at in_progress no longer flip has_incomplete_items) and preflight built-in-tool allowlist kept as-is.
|
Merged via #48108 — your commit was cherry-picked onto current main with your authorship preserved, plus two review-driven corrections:
The incomplete-guard (server-side *_call items at in_progress no longer flipping the incomplete verdict) and the preflight built-in-tool allowlist — the real heart of the fix — went in as-is. Solid root-causing on the stalled-search-loop bug. Thanks! #48108 |
…tx to 200k Salvage corrections on top of @XVVH's NousResearch#44341: - Make native web_search injection a 1:1 swap for an already-present client web_search function, NOT an additive grant. The original unconditionally appended {"type":"web_search"} on every is_xai_responses turn with any tools, force-enabling Grok server-side search even when the user never enabled the web toolset (bypassing Hermes web-provider config + tool-trace plumbing). Now gated on a client web_search actually being present. - Reconcile grok-composer context to 200000 (merged in NousResearch#47908) rather than 262144; 200k is xAI's published usable context window for Composer 2.5, 262144 is the /v1/responses input+output budget. - Update tests to match scoped behavior + add a no-web-toolset guard test. - AUTHOR_MAP entry for NousResearch#44341 salvage. Incomplete-guard (server-side *_call items at in_progress no longer flip has_incomplete_items) and preflight built-in-tool allowlist kept as-is.
…tx to 200k Salvage corrections on top of @XVVH's NousResearch#44341: - Make native web_search injection a 1:1 swap for an already-present client web_search function, NOT an additive grant. The original unconditionally appended {"type":"web_search"} on every is_xai_responses turn with any tools, force-enabling Grok server-side search even when the user never enabled the web toolset (bypassing Hermes web-provider config + tool-trace plumbing). Now gated on a client web_search actually being present. - Reconcile grok-composer context to 200000 (merged in NousResearch#47908) rather than 262144; 200k is xAI's published usable context window for Composer 2.5, 262144 is the /v1/responses input+output budget. - Update tests to match scoped behavior + add a no-web-toolset guard test. - AUTHOR_MAP entry for NousResearch#44341 salvage. Incomplete-guard (server-side *_call items at in_progress no longer flip has_incomplete_items) and preflight built-in-tool allowlist kept as-is.
…tx to 200k Salvage corrections on top of @XVVH's NousResearch#44341: - Make native web_search injection a 1:1 swap for an already-present client web_search function, NOT an additive grant. The original unconditionally appended {"type":"web_search"} on every is_xai_responses turn with any tools, force-enabling Grok server-side search even when the user never enabled the web toolset (bypassing Hermes web-provider config + tool-trace plumbing). Now gated on a client web_search actually being present. - Reconcile grok-composer context to 200000 (merged in NousResearch#47908) rather than 262144; 200k is xAI's published usable context window for Composer 2.5, 262144 is the /v1/responses input+output budget. - Update tests to match scoped behavior + add a no-web-toolset guard test. - AUTHOR_MAP entry for NousResearch#44341 salvage. Incomplete-guard (server-side *_call items at in_progress no longer flip has_incomplete_items) and preflight built-in-tool allowlist kept as-is.
…tx to 200k Salvage corrections on top of @XVVH's NousResearch#44341: - Make native web_search injection a 1:1 swap for an already-present client web_search function, NOT an additive grant. The original unconditionally appended {"type":"web_search"} on every is_xai_responses turn with any tools, force-enabling Grok server-side search even when the user never enabled the web toolset (bypassing Hermes web-provider config + tool-trace plumbing). Now gated on a client web_search actually being present. - Reconcile grok-composer context to 200000 (merged in NousResearch#47908) rather than 262144; 200k is xAI's published usable context window for Composer 2.5, 262144 is the /v1/responses input+output budget. - Update tests to match scoped behavior + add a no-web-toolset guard test. - AUTHOR_MAP entry for NousResearch#44341 salvage. Incomplete-guard (server-side *_call items at in_progress no longer flip has_incomplete_items) and preflight built-in-tool allowlist kept as-is.
…tx to 200k Salvage corrections on top of @XVVH's NousResearch#44341: - Make native web_search injection a 1:1 swap for an already-present client web_search function, NOT an additive grant. The original unconditionally appended {"type":"web_search"} on every is_xai_responses turn with any tools, force-enabling Grok server-side search even when the user never enabled the web toolset (bypassing Hermes web-provider config + tool-trace plumbing). Now gated on a client web_search actually being present. - Reconcile grok-composer context to 200000 (merged in NousResearch#47908) rather than 262144; 200k is xAI's published usable context window for Composer 2.5, 262144 is the /v1/responses input+output budget. - Update tests to match scoped behavior + add a no-web-toolset guard test. - AUTHOR_MAP entry for NousResearch#44341 salvage. Incomplete-guard (server-side *_call items at in_progress no longer flip has_incomplete_items) and preflight built-in-tool allowlist kept as-is.
Summary
Fixes grok-composer-2.5-fast (and other xAI OAuth /
codex_responses) sessions that failed web-research turns or showed a 131k context cap.Supersedes the earlier context-only PR #40046 (closed while we finished root-causing search). This is one consolidated change: metadata + transport + adapter.
Problems
Context:
grok-composer-2.5-fastis absent fromGET /v1/modelson OAuth; Hermes fell through to the genericgrok→ 131072 substring rule. Live/v1/responsesenforces ~262144 total (input+output). Users hit premature compression and a misleading context UI.Incomplete loop: When Hermes declared
web_searchas a client function, xAI routed to server-side search without a matching{"type":"web_search"}built-in. Streams often ended reasoning-only →finish_reason="incomplete"→ three continuation retries →Codex response remained incomplete after 3 continuation attempts.Declaration: xAI returns HTTP 400 on duplicate tool names if both client
web_searchand native built-in are sent. Fix: foris_xai_responses, drop the client function and inject native{"type":"web_search"}(same path for composer and grok-4.x).Changes
agent/model_metadata.py"grok-composer": 262144agent/transports/codex.pyweb_searchfor xAI Responsesagent/codex_responses_adapter.py*_callitems (e.g.web_search_call) when judging incomplete; preflight allowlist for built-in tool typesTests
118 passed on this branch.
Trade-off (explicit)
On xAI Responses,
web_searchuses Grok's native search, not Hermes Tavily/citation plumbing. Results appear in the assistant message rather than as a client-observed tool result. Scoped tois_xai_responsesonly; other providers unchanged.Verification
Related