[pull] main from danny-avila:main#99
Merged
Merged
Conversation
* 🧠 fix: Recognize non-Anthropic reasoning blocks in pruner Long conversations with reasoning-capable non-Anthropic/non-Bedrock providers (DeepSeek-R1's `reasoning_content`, DashScope/Qwen-thinking via OpenAI-compat surfaces) threw fatal 500s once `getMessagesWithinTokenLimit` ran, permanently bricking the thread on every retry. Root cause: the pruner searched the assistant content for a reasoning block by `content.type === reasoningType`, and `reasoningType` only resolves to `reasoning_content` for Bedrock — every other provider defaults to `thinking`. DeepSeek/Qwen blocks are tagged `reasoning_content` and are not normalized upstream (`modifyDeltaProperties` runs only for Anthropic and Bedrock), so the strict find missed the present block and execution fell through to the malformed-payload throws. - Match any reasoning shape (`thinking` or `reasoning_content`) via a shared `findReasoningBlock` helper, so the block is located by whichever tag the provider actually emitted. This also covers custom OpenAI-compat endpoints, which a provider-name check cannot. - Degrade the two post-loop throws to a graceful return of the partially-pruned context, so a missing/mislabeled block surfaces a recoverable provider error instead of a fatal that bricks the conversation. - Null-guard the `addThinkingBlock` content access for empty content arrays. Adds regression tests for both the find path and the graceful-degradation path; each was confirmed to reproduce the corresponding pre-fix throw. Resolves #191 * 🧠 fix: Address Codex review on reasoning-block pruning - Restrict the cross-type reasoning match to one direction: the THINKING default also accepts `reasoning_content` (the DeepSeek/Qwen fix), but a Bedrock run (REASONING_CONTENT) no longer matches an Anthropic `thinking` block — the Bedrock converter rejects `thinking`, so reattaching one would fail the request. - Clear `thinkingStartIndex` in the graceful-degradation path when no block is found, so a stale carried-over index isn't persisted as `runThinkingStartIndex` and doesn't suppress the trailing scan on later turns. Adds regression tests for both (Bedrock must not match a thinking block; the graceful path must not propagate a stale index).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )