fix(session): restore persisted stats when resuming a session#876
Open
abhay-codes07 wants to merge 1 commit into
Open
fix(session): restore persisted stats when resuming a session#876abhay-codes07 wants to merge 1 commit into
abhay-codes07 wants to merge 1 commit into
Conversation
Resuming a session showed the context indicator at 0% (and zeroed session totals) until the first new completion arrived, because stats.context_tokens is only updated from live LLM usage. The values are already persisted in the session metadata on every interaction; none of the resume paths read them back. Add AgentStats.restore_from_session, which validates the persisted payload and copies the values onto the live stats object in place so registered listeners fire and existing references stay valid, and call it from all three resume paths: vibe --resume/--continue at startup, the in-app session picker, and the ACP loadSession handler (which also sends its usage update from these stats). Invalid or missing stats payloads are ignored. Fixes mistralai#712 Fixes mistralai#713
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 #712
Fixes #713
After resuming a session the context indicator in the bottom right shows 0% (and the session totals reset) until the first new completion arrives. The messages restore fine; only the stats are lost.
Root cause:
stats.context_tokensis only ever set from live LLM usage in the agent loop. The values are already persisted in the session metadata on every interaction (save_interactionwritesstats.model_dump()), but none of the resume paths read them back.Change:
AgentStats.restore_from_session(data): validates the persisted payload and copies the values onto the live stats object field by field, in place, so listeners registered on the object (like the context progress meter) fire and existing references stay valid. Invalid or missing payloads are ignored silently, matching how the rest of the metadata is read defensively.vibe --resume/--continueat startup, the in-app session picker, and the ACPloadSessionhandler. The ACP path also sends a usage update right after loading, which previously reported zeros.Testing:
@elGrogz two long-standing duplicate reports close with this one.