fix(agent-runtime): backfill reasoning_content for relayed DeepSeek models - #232
Merged
Merged
Conversation
…odels pi-ai only gave assistant messages without thinking an empty reasoning_content when the model was flagged `reasoning`. A DeepSeek model reached through a relay is not in the catalogue, so the flag is false, the backfill never ran, and a history in which only some turns carry thinking was sent as is; DeepSeek answers that mix with HTTP 400 while all-or-none is accepted (vastsa#223). Extend the pnpm patch on @earendil-works/pi-ai: after converting the messages, whenever any assistant message carries reasoning_content, the remaining assistant messages get an empty one. The per-message backfill for flagged models is unchanged.
|
@L4XB is attempting to deploy a commit to the vastsa's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
Reviewed and merged as commit 370f076. The change is scoped to the patched pi-ai OpenAI-completions replay path: when DeepSeek-compatible history contains a non-empty reasoning_content on any assistant turn, missing assistant turns receive an empty value, while all-no-thinking histories remain unchanged. Validation passed: focused regression 2/2, agent-runtime typecheck, all 353 agent-runtime tests, and protocol smoke E2E 18/18 (2 live-model cases skipped because credentials were not configured). CI JS and Rust checks were green; the Vercel status requires deployment authorization and was not a code failure. |
vastsa
added a commit
that referenced
this pull request
Sep 11, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refs #223 (the backfill part, "B" in the report)
Problem
In
@earendil-works/pi-aiconvertMessages()(dist/api/openai-completions.js) thereasoning_content: ""backfill is guarded bymodel.reasoningisfalsefor a DeepSeek model reached through a relay (not in the models.dev catalogue, nothinkingLevels), so even with the compat flag set the backfill never ran. A session whose history contains some assistant turns with thinking and some without was sent as a mix; as the report measured, DeepSeek rejects the mix with HTTP 400 and accepts all-or-none.Change
The repo already patches pi-ai (
patches/@earendil-works__pi-ai@0.85.1.patch), so the patch is extended (viapnpm patch/pnpm patch-commit, hence thepnpm-lock.yamlhash change):convertMessages(), ifcompat.requiresReasoningContentOnAssistantMessagesis set and any assistant message ends up with a non-emptyreasoning_content, every other assistant message getsreasoning_content: "".reasoningis untouched, and a history without any thinking is left exactly as before (noreasoning_contentat all).Not included: the report's part "A" (treating any model whose id contains
deepseekas a DeepSeek target).deepseekRequestCompat()inpackages/shared/src/provider-presets.tsalready matches on the provider key or adeepseek.combase URL; widening that to arbitrary relay base URLs by model id is a product decision I did not want to take here.Tests
packages/agent-runtime/src/reasoning-content-backfill.test.tscalls the exportedconvertMessageswith areasoning: falsemodel and the DeepSeek compat:["let me think", ""];[undefined, undefined].Verified locally:
vitest run src/reasoning-content-backfill.test.ts(2 passed),tsc -p tsconfig.json --noEmitinpackages/agent-runtime,pnpm installapplies the updated patch.