fix(core): preserve reasoning metadata on errored assistant turns - #38711
fix(core): preserve reasoning metadata on errored assistant turns#38711loulanyue wants to merge 1 commit into
Conversation
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.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
|
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 |
|
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. |
Fixes #38620.
Anthropic rejects a replayed
tool_usewith a 400 if its precedingthinkingblock is dropped when extended thinking is enabled.Previously,
reuseProviderMetadatarequiredmessage.error === undefined, meaning an aborted/failed step would drop all reasoning state on replay (bothanthropic.signatureandanthropic.redactedData) while still replaying that same message'stool_useparts.This relaxes the guard strictly for reasoning blocks, ensuring the signature is retained when
sameModelis true. This keeps the block from being filtered out as empty, keeping the message structurally valid for the provider.