Repository navigation
Conversation
`globalVersion` starts at `0`, which matches the default session snapshot version. The refresh guard (`snapshotVersion > 0`) therefore always evaluates to `false` after a gateway restart, so sessions created before the restart keep their stale skills snapshot indefinitely. Initialize `globalVersion` to `Date.now()` so that any pre-existing session snapshot (version `0` or from a previous boot) is correctly detected as stale and rebuilt on the next agent turn. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Greptile SummaryThis PR fixes a one-line bug where The fix (
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/skills/refresh.ts
Line: 27
Comment:
**Consider adding a regression test for this initialization**
The fix is correct, but `refresh.test.ts` currently has no coverage for `getSkillsSnapshotVersion` or the initial value of `globalVersion`. Without a test, the same bug (e.g. someone resetting it back to `0` or adding an early-return path that re-initialises it) could silently regress.
A lightweight test in `refresh.test.ts` could assert that the version is `> 0` immediately after module load and that it is strictly greater than a session snapshot version of `0`:
```ts
it("initial globalVersion is > 0 so stale session snapshots are always detected", async () => {
const mod = await import("./refresh.js");
const version = mod.getSkillsSnapshotVersion();
expect(version).toBeGreaterThan(0);
// Simulates a persisted session with default version 0
expect(version).toBeGreaterThan(0); // snapshotVersion > 0 guard passes
});
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: cf6ab7b |
| const workspaceVersions = new Map<string, number>(); | ||
| const watchers = new Map<string, SkillsWatchState>(); | ||
| let globalVersion = 0; | ||
| let globalVersion = Date.now(); |
There was a problem hiding this comment.
Consider adding a regression test for this initialization
The fix is correct, but refresh.test.ts currently has no coverage for getSkillsSnapshotVersion or the initial value of globalVersion. Without a test, the same bug (e.g. someone resetting it back to 0 or adding an early-return path that re-initialises it) could silently regress.
A lightweight test in refresh.test.ts could assert that the version is > 0 immediately after module load and that it is strictly greater than a session snapshot version of 0:
it("initial globalVersion is > 0 so stale session snapshots are always detected", async () => {
const mod = await import("./refresh.js");
const version = mod.getSkillsSnapshotVersion();
expect(version).toBeGreaterThan(0);
// Simulates a persisted session with default version 0
expect(version).toBeGreaterThan(0); // snapshotVersion > 0 guard passes
});Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/skills/refresh.ts
Line: 27
Comment:
**Consider adding a regression test for this initialization**
The fix is correct, but `refresh.test.ts` currently has no coverage for `getSkillsSnapshotVersion` or the initial value of `globalVersion`. Without a test, the same bug (e.g. someone resetting it back to `0` or adding an early-return path that re-initialises it) could silently regress.
A lightweight test in `refresh.test.ts` could assert that the version is `> 0` immediately after module load and that it is strictly greater than a session snapshot version of `0`:
```ts
it("initial globalVersion is > 0 so stale session snapshots are always detected", async () => {
const mod = await import("./refresh.js");
const version = mod.getSkillsSnapshotVersion();
expect(version).toBeGreaterThan(0);
// Simulates a persisted session with default version 0
expect(version).toBeGreaterThan(0); // snapshotVersion > 0 guard passes
});
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Closing this as duplicate or superseded after Codex automated review. PR #48500 describes a real stale skills snapshot restart bug that still exists in the checked-out main, but the remaining work is now superseded by canonical maintainer PR #71497. That PR is open/draft, labeled Best possible solution: Close #48500 as superseded by canonical maintainer PR #71497, and keep the implementation, regression test, and changelog entry concentrated in that current-file-layout fix. What I checked:
So I’m closing this here and keeping the remaining discussion on the canonical linked item. Codex Review notes: model gpt-5.5, reasoning high; reviewed against 62869c85025b. |
Summary
sessions.jsonto pick up new skills — a confusing workaround that shouldn't be needed.globalVersioninsrc/agents/skills/refresh.tsinitialized toDate.now()instead of0, plus a regression test.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
After a gateway restart, agents in existing sessions now correctly see newly installed skills without requiring manual deletion of session entries from
sessions.json.Security Impact (required)
NoNoNoNoNoRepro + Verification
Environment
Steps
skillsSnapshot.version: 0)SKILL.mdto workspace skills dir)Expected
Actual
snapshotVersion > 0evaluates tofalsebecauseglobalVersionstarts at0.Evidence
The new regression test (
getSkillsSnapshotVersion > initial globalVersion is > 0) fails with the oldlet globalVersion = 0and passes withDate.now().Root cause trace:
session-updates.ts:185:snapshotVersion > 0 && (nextEntry?.skillsSnapshot?.version ?? 0) < snapshotVersiongetSkillsSnapshotVersion()returnsglobalVersion(=0before fix)0 > 0→false→shouldRefreshSnapshot = false→ stale snapshot reusedHuman Verification (required)
session-updates.ts:182-228confirming that existing sessions (isFirstTurnInSession = false) rely entirely onshouldRefreshSnapshotto rebuild skill snapshots.bumpVersion()already producesDate.now()-scale numbers, soDate.now()initialization is consistent with the version space.workspaceVersionsmap entries default to0via?? 0but are always combined withMath.max(globalVersion, local), so the fix covers workspace-scoped versions too.Review Conversations
Compatibility / Migration
YesNoNoFailure Recovery (if this breaks)
let globalVersion = 0src/agents/skills/refresh.tsRisks and Mitigations