Skip to content

🪃 fix: Skip Reasoning Replay for Grok 4.7 on Bedrock - #737

Merged
danny-avila merged 1 commit into
mainfrom
lia/bedrock-xai-reasoning-replay
Nov 23, 2026
Merged

danny-avila merged 1 commit into
mainfrom
lia/bedrock-xai-reasoning-replay

Conversation

@lia-by-librechat

Copy link
Copy Markdown
Contributor

Fixes #728. Supersedes #729.

What broke

Grok 4.7 on Bedrock (us.xai.grok-4.7) returns reasoningContent with its tool calls and rejects it when replayed:

ValidationException: This model doesn't support the reasoningContent.reasoningText.text field for assistant messages.

Every tool loop fails on its second request, streaming and non-streaming.

Fix

  • utils/message_inputs.ts: private bedrockReplayException(model) classifies openai or grok-4.7 from 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: drives invoke and stream through a spied BedrockRuntimeClient.send for us.xai.grok-4.7, an inference-profile ARN naming it, and xai.grok-4.7 with an application inference profile. Asserts reasoning omitted, tool pairing kept, modelId correct, caller's message not mutated. All 3 cases fail on main.

Claude, unknown families, opaque ARNs and Grok 4.6 keep replaying.

Why a replacement for #729

main pins global.xai.grok-4.6 as 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 every xai. 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:

Check Result
Focused Bedrock jest (8 suites) 134 passed
reasoning-replay.test.ts on main sources 3 new cases fail
npx tsc --noEmit clean
npx eslint (3 files) clean
node scripts/sort-imports.ts --check (3 files) clean

Not run: full suite, live AWS.

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).
@lia-by-librechat

Copy link
Copy Markdown
Contributor Author

Head dddf592caec0f558feab00210ed2cf75e5e3f3d6: single commit on main e1ecea824ba13af85186ba04bc6a920360fca07c. Carries the Grok 4.7 replay exception in src/llm/bedrock/utils/message_inputs.ts, the non-streaming converter switch in src/llm/bedrock/index.ts, and the invoke/stream regression cases in src/llm/bedrock/reasoning-replay.test.ts. Offline checks only: 134 focused Bedrock tests pass, tsc --noEmit, eslint and import order clean.

@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review the latest head, final review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T14:52:01.095305Z dddf592 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: dddf592cae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danny-avila
danny-avila merged commit 6a1d8a7 into main Nov 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock: xAI (Grok) models fail on the second step of any tool call because reasoning is replayed

2 participants