fix(gateway): rotate already-stale generated transcript filename on /reset#93496
Merged
vincentkoc merged 2 commits intoJun 16, 2026
Merged
Conversation
Member
|
Land-ready maintainer review complete.
The maintainer prepare gate build passed. Its first local |
vincentkoc
force-pushed
the
fix/reset-rotate-stale-transcript
branch
2 times, most recently
from
June 16, 2026 06:31
10f9768 to
09eddec
Compare
…reset Gateway /reset rotated the transcript filename keyed by previousSessionId = currentEntry.sessionId, so a post-upgrade sessionFile whose basename already embeds a different generated id stayed stale: the new session kept writing to <old-id>.jsonl while its header carried the new id. Key rotation off the file's embedded id (extractGeneratedTranscriptSessionId) so already-stale generated names rotate too; explicit custom paths have no embedded id and stay preserved. Refs openclaw#77770 Co-Authored-By: Claude Opus 4.8 <[email protected]>
vincentkoc
force-pushed
the
fix/reset-rotate-stale-transcript
branch
from
June 16, 2026 06:32
09eddec to
6ae356c
Compare
Member
|
Merged via squash.
Thanks @harjothkhara! |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jun 17, 2026
…reset (openclaw#93496) Merged via squash. Prepared head SHA: 6ae356c Co-authored-by: harjothkhara <[email protected]> Co-authored-by: vincentkoc <[email protected]> Reviewed-by: @vincentkoc
crh-code
pushed a commit
to crh-code/openclaw
that referenced
this pull request
Jun 18, 2026
…reset (openclaw#93496) Merged via squash. Prepared head SHA: 6ae356c Co-authored-by: harjothkhara <[email protected]> Co-authored-by: vincentkoc <[email protected]> Reviewed-by: @vincentkoc
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
Gateway session
/resetmints a new session id but, when the storedsessionFilebasename still embeds a generated id that differs from the entry's logicalsessionId(the post-upgrade "already-stale" state), keeps the new session writing to the old<stale-id>.jsonl. The old transcript is archived as<stale-id>.jsonl.reset.<ts>, yet the new active transcript reuses the stale filename even though its header carries the new session id.resolveResetSessionFilerotated the filename viarewriteSessionFileForNewSessionId({ previousSessionId: currentEntry.sessionId }), which only matches when the basename equals the current logical id. This change keys rotation off the file's actual embedded id using the existingextractGeneratedTranscriptSessionIdclassifier, so already-stale generated names rotate too. Explicit custom transcript paths have no embedded id and are preserved unchanged.src/gateway/session-reset-service.ts(resolveResetSessionFile); exportsextractGeneratedTranscriptSessionIdfromsrc/gateway/session-transcript-files.fs.ts.Refs #77770
Real behavior proof
Behavior addressed: TUI/Gateway
/resetreused a stale generated transcript filename (<old-id>.jsonl) for the new session when the storedsessionFileembedded an id different from the entry's logicalsessionId, so the new session id in the transcript header no longer matched its filename.Real environment tested: macOS (darwin 25.5.0), repo Node toolchain. Drove the production gateway reset entry point
performGatewaySessionReset(the exact functionsessions.reset/ TUI/resetinvoke) against a real on-disk session store under a throwawayOPENCLAW_HOME. No mocks, no test harness.Exact steps or command run after this patch:
sessions.jsonat<state>/agents/main/sessions/in the post-upgrade stale state: entryagent:main:main={ sessionId: 2222…, sessionFile: <dir>/1111….jsonl }, with the real1111….jsonltranscript on disk.performGatewaySessionReset({ key: "main", reason: "reset", commandSource: "proof:77770" }).sessions.jsonand list the sessions dir.Run as
OPENCLAW_HOME=<tmp> node_modules/.bin/tsx driver.mtsfrom the repo root (driver reproduced below).Evidence after fix:
Same driver on current
main(before this patch):Observed result after fix: the new session's active transcript filename matches its new session id (
<new-id>.jsonl) and the stale file is archived as<old-id>.jsonl.reset.<ts>. Onmainthe active transcript stays<old-id>.jsonlwhile the header id advances — reproducing the report.What was not tested: I drove the gateway reset runtime directly rather than typing
/resetin the interactive TUI (the TUI is a thin client issuing exactly thissessions.resetcall). Topic/fork stale variants are covered by unit tests only; no live channel was exercised.Tests and validation
pnpm test src/gateway/server.sessions.reset-models.test.ts→ 18 passed, including a new stale-embedded-id rotation case. The new test is red on both gateway shards without the source fix and green with it (verified by reverting the fix).pnpm tsgo:core✓ ·pnpm tsgo:test:src✓ ·pnpm exec oxfmt --check✓ ·oxlint✓ · core-boundary + session-accessor-boundary guards ✓.Risk / scope
Bounded runtime fix: one function plus one new export, reusing the existing
extractGeneratedTranscriptSessionIdclassifier (no duplicated grammar). Custom transcript placements are unaffected (covered by the existing ownership-metadata test). No config, migration, or security surface touched.Proof driver (driver.mts)