fix(reasoning): close rounds on tool-result evidence, not user messages - #349
Merged
Merged
Conversation
…es (#348) Long agentic sessions have no user messages after the opening prompt, so the old 'genuine user message after the compress call' closure gate was unreachable — every compress stayed 'active' forever and its thinking survived as a permanent uncompressible floor (0 drops observed; 20.6K / 8.4K / 10.6K chars retained in session 01a086ff). A round is now closed when EVERY compress toolCall in the message has its toolResult (role toolResult, matching toolCallId) at a later index and at least one message exists after that result. In-flight calls (result missing or still the last message) stay untouched; the nudge push runs after the drop so a synthetic nudge can never close a round; per-provider compress.providers.<name>.reasoning.drop=false remains the escape hatch for reasoning-replay providers (GLM). Verified against the real session through the full transform pipeline: compress-anchor thinking 20612 -> 0 chars with threshold:1, non-compress thinking untouched. Tests: rewritten gate suite + new #348 scenarios (no-user-message assistant chain, pending result, result-before-call, mismatched id, mixed calls).
📦 Built Extension ArtifactBranch: Option A — Install from npm PR tag (recommended)pi install npm:billion-context-pi@pr-349Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pi-pr349.tgz
pi install ./packageThis comment is automatically updated on each push. |
ranxianglei
pushed a commit
that referenced
this pull request
Sep 9, 2026
Merged
HangxiangMa
pushed a commit
to HangxiangMa/billion-context-pi
that referenced
this pull request
Sep 10, 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.
Fixes #348
Problem
The
compress.reasoningdrop (shipped in #339, aligned with opencode-acp #377) closed a turn only when a genuine user message existed after the compress call. Long agentic sessions have no user messages after the opening prompt (observed: session 01a086ff — 64 entries, only 2 genuine user messages, 30 compress calls), so every compress round stayed "active" forever and its thinking survived as a permanent uncompressible floor. Observed withthreshold: 1: 0 drop events; retained thinking 20612 / 8411 / 10581 chars.Fix
Round closure is now judged on round evidence:
compresstoolCall in the message has its toolResult (roletoolResult, matchingtoolCallId) at a later index, andSafety gates preserved:
compress.providers.<name>.reasoning.drop = falseremains the escape hatch for reasoning-replay providers (GLM).Verification
threshold: 1): compress-anchor thinking 20612 → 0 chars, deterministic across runs; non-compress thinking (82–1893 chars) untouched.npm run typecheckclean.Repro artifacts:
~/tmp/repro-rd.mjs(drives the dist transform with the real session entries).