Repository navigation
🪃 fix: Skip Reasoning Replay for Grok 4.7 on Bedrock - #737
Conversation
Grok 4.7 on Bedrock returns reasoningContent with its tool calls and rejects it when replayed, so every tool loop failed on its second request. Omit the replay on the streaming and non-streaming Converse paths, including named inference profiles and application profiles. Other families, Grok 4.6 and opaque resources keep the existing behavior. Design credit: umzcio (#729; reported #728).
|
Head |
|
@codex review the latest head, final review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ 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". |
Fixes #728. Supersedes #729.
What broke
Grok 4.7 on Bedrock (
us.xai.grok-4.7) returnsreasoningContentwith its tool calls and rejects it when replayed:Every tool loop fails on its second request, streaming and non-streaming.
Fix
utils/message_inputs.ts: privatebedrockReplayException(model)classifiesopenaiorgrok-4.7from a plain id, a geo/global profile id, or a foundation-model/inference-profile ARN.replaysBedrockReasoning()is false for both. Harmony neutralization stays OpenAI-only.index.ts: the non-streaming path uses the local converter whenever replay is suppressed.reasoning-replay.test.ts: drivesinvokeandstreamthrough a spiedBedrockRuntimeClient.sendforus.xai.grok-4.7, an inference-profile ARN naming it, andxai.grok-4.7with an application inference profile. Asserts reasoning omitted, tool pairing kept,modelIdcorrect, caller's message not mutated. All 3 cases fail onmain.Claude, unknown families, opaque ARNs and Grok 4.6 keep replaying.
Why a replacement for #729
mainpinsglobal.xai.grok-4.6as still replaying reasoning (src/llm/bedrock/utils/cross-model-reasoning.test.ts, family list at line 172 and assertion at line 228, added by #581). #729 matches everyxai.model and does not touch that test. This reading comes from #729's description and published diff; its branch was not checked out or run.Report, diagnosis and live verification are @umzcio's (#728, #729).
Scope decision for the maintainer
Only Grok 4.7 has live evidence, so only it is matched. Widening to all xAI is a one-line regex change plus the 4.6 test.
Verification
Live Bedrock results are author-reported in #729. Checks here are offline:
reasoning-replay.test.tsonmainsourcesnpx tsc --noEmitnpx eslint(3 files)node scripts/sort-imports.ts --check(3 files)Not run: full suite, live AWS.