Skip to content

fix(core): preserve reasoning metadata on errored assistant turns - #38711

Closed
loulanyue wants to merge 1 commit into
anomalyco:devfrom
loulanyue:fix/38620-errored-reasoning-metadata
Closed

fix(core): preserve reasoning metadata on errored assistant turns#38711
loulanyue wants to merge 1 commit into
anomalyco:devfrom
loulanyue:fix/38620-errored-reasoning-metadata

Conversation

@loulanyue

Copy link
Copy Markdown

Fixes #38620.

Anthropic rejects a replayed tool_use with a 400 if its preceding thinking block is dropped when extended thinking is enabled.

Previously, reuseProviderMetadata required message.error === undefined, meaning an aborted/failed step would drop all reasoning state on replay (both anthropic.signature and anthropic.redactedData) while still replaying that same message's tool_use parts.

This relaxes the guard strictly for reasoning blocks, ensuring the signature is retained when sameModel is true. This keeps the block from being filtered out as empty, keeping the message structurally valid for the provider.

Fixes anomalyco#38620. Anthropic rejects a replayed `tool_use` if its preceding `thinking` block is dropped. By relaxing the `message.error === undefined` guard for reasoning blocks, we ensure the signature remains and the block is not filtered out as empty, keeping the message valid for the provider.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR that may be addressing similar concerns about reasoning metadata preservation:

Related PR:

However, this appears to be an older PR and addresses a different aspect of the problem. The current PR (#38711) is specifically fixing the issue where reasoning metadata is dropped on errored/aborted assistant turns during replay, which is a distinct bug from preserving thinking blocks in general transforms.

No duplicate PRs found

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 24, 2026
@github-actions github-actions Bot closed this Jul 24, 2026
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.

V2: errored-message replay can 400 with Anthropic thinking + tool use

1 participant