fix(v2): persist SDK session ID across container restarts

The v2 poll loop held the session ID in a local variable, so every
container restart started a fresh SDK session even though the .jsonl
transcript was still sitting in the shared .claude mount. Store it in
outbound.db (container-owned, already per channel/thread), seed the
loop on startup, clear on /clear, and recover from stale-session
errors the same way v1 did.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-04-11 01:17:42 +03:00
parent b591d7ce96
commit b59216c299
4 changed files with 95 additions and 4 deletions

View File

@@ -140,4 +140,13 @@ CREATE TABLE processing_ack (
status TEXT NOT NULL,
status_changed TEXT NOT NULL
);
-- Persistent key/value state owned by the container. Used (among other things)
-- to store the SDK session ID so the agent's conversation resumes across
-- container restarts. Cleared by /clear.
CREATE TABLE session_state (
key TEXT PRIMARY KEY,
value TEXT NOT NULL,
updated_at TEXT NOT NULL
);
`;