Repository navigation
fix(core): omit truncated reasoning-only history on recovery - #61439
HaiYangBG1 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
The fix works. With the #60292 reproduction (a fake strict OpenAI-compatible server, opencode run --standalone), the base sends assistant(content="", reasoning_content=…) in the recovery request, gets a 400 and exits with code 1. With this change, the recovery request is [system, user, user(nudge)] and the run exits with code 0. The runner and message suites pass (273/273).
The check is narrow: only turns that stopped at the output limit and contain nothing but reasoning are left out. Their tool results are still returned, and the turn stays in stored history, so the repeated-length guard in llm.ts is unaffected. Anthropic, Bedrock and Gemini allow dropping a thinking block from a turn without tool use, so signed reasoning replay doesn't break.
Public API: unchanged.
No blocking concerns.
Related: #46881
There was a problem hiding this comment.
The new commit only merges dev; the change itself is the same as before. I re-ran the #60292 reproduction on the new base: the base still gets the 400 and exits with code 1, and with this PR the recovery request contains no empty assistant message and the run exits with code 0. The runner and message suites pass (274/274), and tsc -b is clean.
Public API: unchanged.
No new concerns.
There was a problem hiding this comment.
The new commit only merges dev; the change itself is unchanged. I re-ran the #60292 reproduction on the new base: the base still gets the 400 and exits with code 1, and with this PR the recovery request contains no empty assistant message and the run exits with code 0. The runner and message suites pass (274/274), and tsc -b is clean.
Public API: unchanged.
No new concerns.
Issue for this PR
Fixes #60292
Type of change
What does this PR do?
After a reasoning-only response hits the output limit, the recovery request can replay an assistant message with empty content. Strict OpenAI-compatible providers reject it with 400.
Omit that message from model history only when its finish reason is
lengthand all meaningful parts are reasoning. Keep the original reasoning in stored history and send the existing recovery prompt. Responses containing text or tool calls, and normally completed reasoning, keep their existing handling.This is separate from #56942's empty-content guard: nonempty reasoning survives that guard. Porting its production filtering logic to the same current baseline still reproduces the 400; this comparison does not claim to test the whole older PR branch.
How did you verify your code works?
macOS ARM64, Bun 1.4.4, frozen install; base
ce8ca3084eac.bun run check: lint has no errors (warnings remain), all 35 typecheck tasks passed.git diff --checkpassed.Failure details:
ShellTool conditional process substitution > conditional substitutions respect onceShellTool conditional process substitution > conditional substitutions respect alwaysreal-shell compound syntax: Bash function containingcaseinside command substitution (test/shell-scan/compound-parity.test.ts:125)RepositoryCache > persists the daily throttle across cache recreation and serializes competing refreshesThe three affected files on the clean same-SHA baseline produced 643 passed / 11 skipped / 3 failed, with the same three Shell/Bash failures. After restoring the patch, the cache case and two recovery cases passed 3/3. No assertions, skips or timeouts in the failing tests were changed. Reruns do not replace the full-run result.
To run the focused suite:
cd packages/core && bun run script/test.ts test/session-runner.test.ts test/session-runner-message.test.ts.Linux, Windows, real Kimi service behavior and upstream CI have not been verified locally.
Visual
Screenshots / recordings
No UI change. The before/after check uses the real CLI against a local simulated provider.
Checklist
Added by the opencode bot (AI-generated).
Related: #46881
Upstream sync on 2026-11-05
Head
203be51d5ec52ab4e5eb7fb59fa8883f9181178bmergesdevat8a12d6b4207a2bef758a20fa922a189fe9dea78dand preserves the PR's existing behavior. The session runner and message conversion suites passed 274 tests. On macOS ARM64 with Bun 1.4.4 and frozen dependencies,bun run checkpassed lint with no errors and all 35 typecheck tasks. The normal pre-push hook passed, and the fork branch SHA was read back after the fast-forward push.Earlier runtime and visual evidence above remains tied to its stated commits. These local results do not establish hosted CI approval or release validation.