Why a pool
Spinning up a Claude Agent SDK subprocess per request is expensive (startup cost, MCP attach, system prompt warm-up). For chat-style workloads, a pool of long-lived clients keyed by conversation_id is dramatically faster. cwkPippa's ClaudeSessionManager is exactly this pool.
What the pool owns
The pool owns: lifecycle (connect on first use, disconnect on TTL or shutdown), error handling (replace dead clients), capacity caps (max concurrent subprocesses), and metrics (active count, lifetime, last-use timestamp). Treat it like a database connection pool — the same disciplines apply.
Stale subprocess hygiene
Long-lived subprocesses leak resources if you forget about them. Sweep the pool periodically: drop clients with no activity in N minutes, free their MCP connections, log the reason. Bound the pool size; refuse new sessions when full and surface the failure rather than queuing forever.