Repository navigation
fix(session): reset usage stats when forking a session - #15391
Open
markjoin123 wants to merge 2 commits into
Open
markjoin123 wants to merge 2 commits into
markjoin123 wants to merge 2 commits into
Conversation
Copied assistant turns were counted again as agent runs, tokens, and active time. Mark that history as prior context and clear copied step-finish spend so project totals stay with the work that actually ran.
This branch has not been deployed
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.
Issue
Fixes #15384
Context
Forking a chat copied the parent's assistant turns into the new session, and usage reports treated that copy as new work. Cost stayed the same because fork already zeroed it, but agent runs, tokens, and active time were counted again on every fork, including a fork of a fork.
Implementation
forkedand left out of the agent-usage query (task-child copies included).kilo statsskips those copied rows when rolling up per-model tokens.Screenshots / Video
N/A (no visual change)
How to Test
Manual/local verification
From
packages/opencode/:bun test ./test/kilocode/agent-usage/agent-usage.test.ts --timeout 30000: the new testforking a session does not recount copied runs, tokens, or active timefailed before the fix (one free-model turn became 3 runs, 3x tokens, 3000ms active time after two forks). After the fix: 11 pass, 0 fail.bun test ./test/kilocode/session-fork-remap.test.ts --timeout 30000: 8 pass, 0 failbun test ./test/kilocode/stats-subagent-cost.test.ts --timeout 30000: 1 pass, 0 failbun run typecheckinpackages/opencode/andpackages/schema/: passbun turbo typecheck --filter=!@kilocode/kilo-jetbrains(29/29) and JetBrains typecheck: passReviewer test steps
kilo stats: runs, tokens, and active time should match the original work only.Blocked checks and substitute verification
This change was made with AI assistance and was reviewed and tested before submission.