Skip to content

fix(agent-runtime): preserve DeepSeek reasoning across compaction - #400

Merged
vastsa merged 4 commits into
vastsa:mainfrom
GISWLH:fix/296-compaction-reasoning-content
Sep 15, 2026
Merged

vastsa merged 4 commits into
vastsa:mainfrom
GISWLH:fix/296-compaction-reasoning-content

Conversation

@GISWLH

@GISWLH GISWLH commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Restore DeepSeek-compatible reasoning across Codex-shaped compaction ([Bug] 使用 DeepSeek V4.1 Flash 有概率报错 The reasoning_text in the thinking mode must be passed back to the API. #296): retain recent thinking in checkpoint details.retainedReasoning, restore thinkingSignature on history rebuild, and use a documented non-empty placeholder for non-official DeepSeek Completions rows while official deepseek.com keeps empty-string fill ([Bug] 修复 reasoning_content 传回错误 #223).
  • Review follow-ups: restore \0 separators in mutation grace keys; stamp retained turns with live model identity + non-empty content stand-in so transformMessages/convertMessages keep reasoning-only assistants; keep reasoning-only assistants in the pi-ai patch; strengthen convertMessages/compaction wire proof.
  • Live OpenCode / aggregator verification remains deferred (E2E-005E); unit coverage includes the post-compaction outbound shape under requiresNonEmptyReasoningReplay.

Fixes #296

Test plan

  • packages/agent-runtime vitest: reasoning-replay, reasoning-content-backfill, session-context, provider-binding
  • packages/shared vitest: provider-presets
  • Quick re-verify of grace-key NUL + retained-reasoning wire assertions after merge review
  • Live OpenCode / aggregator check when available (documented deferred)

GISWLH and others added 4 commits September 15, 2026 07:13
Context compaction dropped assistant thinking, and history rebuild omitted
thinkingSignature, so post-compaction Completions requests echoed empty
reasoning fields. OpenCode/third-party DeepSeek relays reject that with 400
(vastsa#296). Retain recent thinking in checkpoint details, restore signatures on
reload, and use a documented non-empty placeholder for non-official DeepSeek
rows while keeping official empty-string backfill (vastsa#223).

Fixes vastsa#296
Restore NUL separators in mutation grace keys, stamp retained thinking with
live model identity and a non-empty content stand-in so transformMessages /
convertMessages no longer drop reasoning-only turns, and keep reasoning-only
assistants in the pi-ai patch. Strengthen vastsa#296 convertMessages proof; note
deferred live OpenCode verification.
Align the compaction retained-reasoning wire fixture to one reasoning field
so history-wide backfill does not add a placeholder alongside real content,
and point the OpenCode header wiring scan at subagent-model-binding.
@vastsa
vastsa merged commit 4e2e005 into vastsa:main Sep 15, 2026
1 check failed
@vastsa

vastsa commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Reviewed and merged. The original three contributor commits are preserved, with landing commit 7a66949 added to scope thinkingSignature and retained-reasoning replay to compatible OpenAI Completions models; Anthropic and other providers keep their existing behavior. Validation on the integrated main: pnpm build:js, pnpm lint, agent-runtime typecheck, 452 agent-runtime tests, 658 shared tests, and pnpm test:e2e (21/21 passed; two live-model checks skipped because PI_DESKTOP_TEST_API_KEY is unset). The repository Vercel check remains red because deployment authorization is required. Live OpenCode/aggregator verification for E2E-005E remains deferred.

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.

[Bug] 使用 DeepSeek V4.1 Flash 有概率报错 The reasoning_text in the thinking mode must be passed back to the API.

2 participants