Reliable Long-Session Recovery and Turn Cost Tracking / 可靠的长会话恢复与本轮费用统计#2299
Open
SivanCola wants to merge 2 commits into
Open
Reliable Long-Session Recovery and Turn Cost Tracking / 可靠的长会话恢复与本轮费用统计#2299SivanCola wants to merge 2 commits into
SivanCola wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7a591aba9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Open
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.
Summary
AppendOnlyLog.totalLengthwhen marking the start of a turn sodiscardCurrentTurndoes not truncate long sessions after the log window is applied.Root-cause notes for #2287
The concrete correctness bug found in this area is the abort/discard index: after the windowed
AppendOnlyLogchange,this.log.lengthis only the retained window size, not the full persisted history length. If an explicit abort withdiscardCurrentTurnhappens in a long session, the rewrite can slice at the wrong index and drop persisted history outside the current window. That changes future prompt prefixes and can damage cache behavior.I did not find the proposed
stripDroppableReasoningContentexplanation to be the primary cause of every tool-call iteration becoming a full cache miss: the strip path skips assistant messages withtool_calls, and ordinary assistant messages stripped before their first inclusion in a later request do not invalidate a previously sent prefix that already contained them. Missing requiredreasoning_contentfor historical thinking-mode assistant messages would also be more likely to surface as a request-shape error than as a silent full-cache-miss loop.Verification
npm run test -- tests/loop-user-persist.test.ts desktop/src/App.test.ts desktop/src/ui/context-panel.test.tsx tests/desktop-btw-status.test.ts tests/desktop-user-message.test.tsnpm run typechecknpm --prefix desktop run buildnpm --prefix dashboard run buildnpm run lint(passes with existingPlanPanel.tsximport-type warning)npm run verify: build, lint, typecheck, and full test suite passed (314test files,4042tests passed,9skipped); the first push attempt failed only at the final GitHub TLS send-pack step and was retried with--no-verifyafter verification had completed.Related to #2287.