Skip to main content

Module pool

Module pool 

Source
Expand description

Session pool — pre-warmed persistent processes with idle reuse.

  • at most max_sessions sessions are checked out at once (semaphore)
  • every session uses PoolConfig::options (hooks, MCP servers, model, …)
  • acquire_with(Checkout { model, effort, permission_mode }) hands out a session with its own model, effort or permission mode; None keeps the pool’s value
  • a returned session is reset before it is handed out again: /clear empties the conversation, and model, effort and permission mode are set for the next checkout, so a task may change them for itself (set_model, set_effort, set_permission_mode) without affecting the next one
  • dead sessions are dropped and replaced by a fresh spawn
  • a session returned while its turn is still running is not reused; it ends once its last handle is dropped (until then it runs outside the max_sessions count)

Structs§

Checkout
Settings for one checkout. None keeps the value from PoolConfig::options.
PoolConfig
Configuration of a SessionPool.
PooledSession
A session borrowed from the pool. Returns to the pool on Drop. Keep clones of session (e.g. inside an Agent) no longer than the PooledSession: after Drop another task may get the same session.
SessionPool
A pool of pre-warmed Claude sessions. Cheap to clone.