Skip to content

fix(agents): repair sanitized replay tool results before send - #67620

Merged
obviyus merged 4 commits into
openclaw:mainfrom
stainlu:fix/issue-66892-minimax-tool-call-id-format
Apr 16, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
stainlu:fix/issue-66892-minimax-tool-call-id-format

Conversation

@stainlu

@stainlu stainlu commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: MiniMax and other hybrid providers using api.minimaxi.com/anthropic (modelApi: "anthropic-messages") generate tool_call_ids in Anthropic's native toolu_* format. The hybrid replay policy (buildHybridAnthropicOrOpenAIReplayPolicy) applied toolCallIdMode: "strict" sanitization that strips ALL non-alphanumeric characters — removing the underscore from toolu_01A09q... → toolu01A09q.... MiniMax's endpoint rejects the mangled ID with error 2013 ("tool_call id format is not supported"), triggering a 7-minute auth cooldown and session crash.
  • Root cause: buildHybridAnthropicOrOpenAIReplayPolicy in src/plugins/provider-replay-helpers.ts calls buildStrictAnthropicReplayPolicy without preserveNativeAnthropicToolUseIds: true. The native Anthropic provider (buildNativeAnthropicReplayPolicyForModel) already sets this flag — the hybrid path was missing it.
  • Fix: Added preserveNativeAnthropicToolUseIds: true to the buildStrictAnthropicReplayPolicy call in the hybrid anthropic-messages branch. Native toolu_* IDs now pass through unsanitized while other synthetic IDs still get strict cleanup. One-line production change + test updates.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

@greptile-apps

greptile-apps Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds preserveNativeAnthropicToolUseIds: true to the anthropic-messages / bedrock-converse-stream branch of buildHybridAnthropicOrOpenAIReplayPolicy, aligning it with buildNativeAnthropicReplayPolicyForModel which already carried that flag. This stops the strict sanitizer from stripping underscores out of toolu_* IDs when MiniMax (and any other hybrid provider using the Anthropic wire format) replays tool calls, eliminating the error-2013 crash and auth cooldown.

Confidence Score: 5/5

Safe to merge — minimal one-line production change with targeted tests covering the fixed and adjacent cases.

The change is a single flag addition that closes a clear parity gap between the native and hybrid Anthropic replay policy builders. No new logic is introduced, the helper already supports the flag, and the existing + new tests validate the before/after behavior for Claude and non-Claude model IDs going through the affected path.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(agents): preserve native Anthropic t..." | Re-trigger Greptile

@stainlu
stainlu force-pushed the fix/issue-66892-minimax-tool-call-id-format branch from a7e55a8 to 8dbaa33 Compare April 16, 2026 11:43
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S and removed extensions: minimax size: XS labels Apr 16, 2026
@obviyus obviyus self-assigned this Apr 16, 2026
@obviyus obviyus changed the title fix(agents): preserve native Anthropic tool IDs for hybrid providers fix(agents): repair sanitized replay tool results before send Apr 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0b7e36f8a

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

@obviyus
obviyus force-pushed the fix/issue-66892-minimax-tool-call-id-format branch from b0b7e36 to 1e8b61c Compare April 16, 2026 12:48

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the MiniMax replay failure came from strict outbound tool-call ID sanitization leaving orphan tool-result ids like ...toolresult1, and confirmed the landed fix re-runs pairing repair on the send path.

Maintainer follow-up: replaced the original hybrid-toolu_* replay-policy change, added focused replay-sanitization coverage, and fixed the current-head review concern by preserving real tool results for aborted assistant spans.

Local gate: pnpm test src/agents/pi-embedded-runner/run/attempt.tool-call-normalization.test.ts src/plugins/provider-replay-helpers.test.ts extensions/minimax/index.test.ts src/agents/tool-call-id.test.ts and pnpm check.

stainlu and others added 4 commits April 16, 2026 18:35
Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 4613f12). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.
@obviyus
obviyus force-pushed the fix/issue-66892-minimax-tool-call-id-format branch from aa00724 to 850aa22 Compare April 16, 2026 13:07

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the MiniMax replay failure came from strict outbound tool-call ID sanitization leaving orphan tool-result ids like ...toolresult1, and confirmed the landed fix re-runs pairing repair on the send path.

Maintainer follow-up: replaced the original hybrid-toolu_* replay-policy change, added focused replay-sanitization coverage, fixed the review-thread concern by preserving real tool results for aborted assistant spans, and rebased the branch onto latest main.

Local gate: pnpm test src/agents/pi-embedded-runner/run/attempt.tool-call-normalization.test.ts src/plugins/provider-replay-helpers.test.ts extensions/minimax/index.test.ts src/agents/tool-call-id.test.ts and pnpm check.

@obviyus
obviyus merged commit c3c7a99 into openclaw:main Apr 16, 2026
27 checks passed

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the MiniMax replay failure came from strict outbound tool-call ID sanitization leaving orphan tool-result ids like ...toolresult1, and confirmed the landed fix re-runs pairing repair on the send path.

Maintainer follow-up: replaced the original hybrid-toolu_* replay-policy change, added focused replay-sanitization coverage, fixed the review-thread concern by preserving real tool results for aborted assistant spans, and rebased the branch onto latest main.

Local gate: pnpm test src/agents/pi-embedded-runner/run/attempt.tool-call-normalization.test.ts src/plugins/provider-replay-helpers.test.ts extensions/minimax/index.test.ts src/agents/tool-call-id.test.ts and pnpm check.

@obviyus

obviyus commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Landed on main.

Thanks @stainlu.

xudaiyanzi pushed a commit to xudaiyanzi/openclaw that referenced this pull request Apr 17, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 4613f12). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
kvnkho pushed a commit to kvnkho/openclaw that referenced this pull request Apr 17, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 4613f12). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
Mquarmoc pushed a commit to Mquarmoc/openclaw that referenced this pull request Apr 20, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 4613f12). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 209daa2). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in ccff69c). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 6450e4b). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 55f96d8). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 95cfbcf). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 643d129). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
Heetisk pushed a commit to Heetisk/openclaw that referenced this pull request Sep 28, 2026
… (thanks @stainlu)

* fix(agents): preserve native Anthropic tool IDs for hybrid providers

Fixes openclaw#66892

MiniMax and other hybrid providers use api.minimaxi.com/anthropic
(modelApi: anthropic-messages), which generates and expects native
Anthropic tool_call_ids in toolu_* format. The hybrid replay policy
(buildHybridAnthropicOrOpenAIReplayPolicy) applied strict
sanitization that stripped underscores from these IDs, causing
MiniMax to reject them with error 2013.

The native Anthropic provider already preserved these IDs via
preserveNativeAnthropicToolUseIds (added in 4613f12). This
commit enables the same flag for the hybrid anthropic-messages
branch, so toolu_* IDs pass through unsanitized while other
synthetic IDs still get strict cleanup.

* fix(agents): repair sanitized replay tool results before send

* fix: repair sanitized replay tool results before send (openclaw#67620) (thanks @stainlu)

* fix: preserve aborted-span tool results during replay sanitize (openclaw#67620) (thanks @stainlu)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [MiniMax Model] Tool call ID format error (code 2013) causes LCM compaction failure and session crash

2 participants