fix(session): persist usage across requests - #3721
Draft
ehz0ah wants to merge 1 commit into
Draft
Conversation
Store usage events durably under the session lock so a later commit can preserve relations, rich skill metadata, and active-count updates across process and request boundaries.
ehz0ah
force-pushed
the
fix/session-used-durability
branch
from
August 4, 2026 02:45
a8097cf to
047521b
Compare
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.
Description
Persist session
/usedrecords across request and process boundaries so a later session commit can update relations and vectoractive_countvalues reliably.Before this change, the HTTP
usedroute only mutated the in-memorySessioninstance created for that request. A separate commit request loaded a fresh instance, so its Phase 2 worker received no usage records. In an isolated baseline server,/usedreturnedcontexts_used: 1, but the subsequent completed commit reportedactive_count_updated: 0and created no usage relation.This change stores pending usage events in a hidden per-session
.usage.jsonlsidecar under the existing Session Phase 1 tree lock. Commit snapshots exact event IDs, carries full usage records through the durable queue payload, consumes only the committed snapshot, and restores it if Phase 1 fails.Human Involvement
Related Issue
No open issue was found for this exact cross-request usage-loss path.
Type of Change
Changes Made
usedroute await lock-protected durable usage persistence.Usagefield, including skill contribution, input, output, success, and timestamp.SessionCommitMsgwhile preserving replay compatibility with legacyusage_urispayloads.Session.used()compatibility.Testing
Commands:
Live isolated HTTP validation used a fresh server/workspace and the supported temporary-upload pipeline:
The fixed-server run also verified all of the following:
/used-> separate/commitreload boundary;Runtime artifact:
/tmp/openviking-memory-research-fixed/usage-smoke-result.jsonin the local validation environment.Checklist
Screenshots (if applicable)
Not applicable.
Additional Notes
Session.used()remains process-local until that same instance commits; HTTP uses the durable async path.