Summary
src/context-engine.ts keeps predicted context in a module-level Map keyed by sessionId. Entries are deleted when assembleContext consumes them, but a session can end or reset without a final assemble call.
Impact
- abandoned sessions can leave stale predicted context entries behind;
- recycled
sessionId values could receive predictions from an earlier session;
- long-running gateway processes can accumulate cache entries over time.
Scope
Lifecycle/cache hygiene bug. Not an immediate crash.
Fix Path
- Clear
predictiveContextCache on before_reset and session_end lifecycle hints.
- Consider a TTL or max-entry cap as a fallback for hosts that do not deliver lifecycle hints reliably.
- Treat
cachedIdentity invalidation separately unless live identity/config reload is explicitly supported.
Verification Target
- Unit test for lifecycle hint clearing.
- Unit test proving stale predictions from an ended session are not reused.
A previous broad PR (#218) touched this but was closed for bundling unrelated changes. Bring this back as a focused cache-lifecycle patch.
– Vale
Summary
src/context-engine.tskeeps predicted context in a module-levelMapkeyed bysessionId. Entries are deleted whenassembleContextconsumes them, but a session can end or reset without a final assemble call.Impact
sessionIdvalues could receive predictions from an earlier session;Scope
Lifecycle/cache hygiene bug. Not an immediate crash.
Fix Path
predictiveContextCacheonbefore_resetandsession_endlifecycle hints.cachedIdentityinvalidation separately unless live identity/config reload is explicitly supported.Verification Target
A previous broad PR (#218) touched this but was closed for bundling unrelated changes. Bring this back as a focused cache-lifecycle patch.
– Vale