Files
cc-connect/core
quabugandClaude Opus 4.6 cd4a85e858 fix(session): invalidate stale agent session IDs on agent type switch (#129)
* fix(session): invalidate stale agent session IDs on agent type switch

When a project's agent type is changed in config (e.g. opencode → pi),
persisted sessions still contain agent_session_id values from the old
agent. The new agent fails to resume these foreign session IDs, causing
errors and empty responses.

Add an `agent_type` field to Session that tracks which agent created the
session ID. On engine startup, InvalidateForAgent() clears session IDs
whose agent_type doesn't match the current agent. All code paths that
set AgentSessionID now also record the agent type.

Closes #128

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add unit test for SessionManager.InvalidateForAgent

Cover the three key cases: mismatched agent type (invalidated),
matching agent type (preserved), and empty agent type (migration-safe).
Also verifies sessions with no agent session ID are untouched.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 14:21:15 +08:00
..
2026-03-13 15:28:33 +11:00
2026-02-28 10:38:24 +08:00