fix(agent-kit): separate session cache per agent #462

Merged
xiaoju merged 1 commits from fix/461-per-agent-session-cache into main 2026-05-24 09:19:51 +00:00
Owner

What

Separate session cache files per agent to prevent session ID conflicts when multiple agents operate on the same thread+role pair.

Why

Previously, all agents shared a single agent-sessions.json cache file keyed by :. When both hermes and claude-code agents executed the same role in a thread, they would overwrite each other's session IDs, breaking session resumption.

Changes

  • getCachePath() now takes agentName parameter and returns -sessions.json
  • getCachedSessionId/setCachedSessionId require agentName as first parameter
  • Agent wrappers (hermes, claude-code) inject their agent name into cache calls
  • Added comprehensive tests for session cache isolation
  • Handle malformed JSON gracefully (treat as empty cache)

Ref

Fixes #461

## What Separate session cache files per agent to prevent session ID conflicts when multiple agents operate on the same thread+role pair. ## Why Previously, all agents shared a single agent-sessions.json cache file keyed by <threadId>:<role>. When both hermes and claude-code agents executed the same role in a thread, they would overwrite each other's session IDs, breaking session resumption. ## Changes - getCachePath() now takes agentName parameter and returns <agent>-sessions.json - getCachedSessionId/setCachedSessionId require agentName as first parameter - Agent wrappers (hermes, claude-code) inject their agent name into cache calls - Added comprehensive tests for session cache isolation - Handle malformed JSON gracefully (treat as empty cache) ## Ref Fixes #461
xiaoju added 1 commit 2026-05-24 09:17:11 +00:00
Each agent now maintains its own session cache file instead of sharing
a single agent-sessions.json. This prevents session ID conflicts when
multiple agents operate on the same thread+role pair.

Changes:
- getCachePath() now takes agentName parameter
- getCachedSessionId/setCachedSessionId require agentName as first param
- Cache files named <agent>-sessions.json (e.g., hermes-sessions.json)
- Agent wrappers inject their agent name into cache calls
- Add comprehensive tests for session cache isolation
- Handle malformed JSON gracefully (treat as empty cache)

Fixes #461
xiaoju merged commit 38112053a0 into main 2026-05-24 09:19:51 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#462