pub struct AcpSession {
pub runtime: AgentRuntime,
pub cwd: PathBuf,
pub turn: u64,
pub session_id: SessionId,
pub transcript: Vec<Message>,
pub cancel_token: Arc<CancellationToken>,
pub system_prompt: Option<String>,
pub mcp_servers: Option<Value>,
pub client_capabilities: Option<ClientCapabilities>,
pub acp_state: Arc<Mutex<AcpClientFsState>>,
pub mcp_child_pids: Vec<u32>,
}Expand description
State for one active ACP session.
Fields§
§runtime: AgentRuntimeThe agent runtime that processes session/prompt requests.
cwd: PathBufThe sandbox root for filesystem tools.
turn: u64Monotonically-increasing turn counter.
session_id: SessionIdSession identifier (copied from the manager’s key for convenience).
transcript: Vec<Message>Accumulated transcript of messages exchanged so far.
cancel_token: Arc<CancellationToken>Cancellation token for the current (or next) agent turn.
Fired by session/cancel; observed by the LLM stream loop
(tokio::select!) and agent→client RPC calls.
This is an Arc<CancellationToken> to guarantee shared ownership
across concurrent tasks (e.g. SSE parse loop and in-flight RPCs).
Dropping the AcpSession does NOT cancel the token if other Arc
clones exist.
system_prompt: Option<String>The original system prompt for this session (used for session/resume).
mcp_servers: Option<Value>MCP server configurations (used for session/resume).
client_capabilities: Option<ClientCapabilities>Client capabilities declared during initialize (S2-E1/E3). Controls conditional registration of ClientReadFile/ClientWriteFile.
acp_state: Arc<Mutex<AcpClientFsState>>Shared ACP client FS state for conditional tool visibility and routing.
mcp_child_pids: Vec<u32>MCP child processes managed by this session (for cleanup on close/load/resume).
Implementations§
Source§impl AcpSession
impl AcpSession
Sourcepub fn refresh_cancel_token(&mut self) -> Arc<CancellationToken> ⓘ
pub fn refresh_cancel_token(&mut self) -> Arc<CancellationToken> ⓘ
Create a fresh CancellationToken for the next turn and wire it
to the agent runtime via set_interrupt_token. Returns an Arc
clone of the new token for the caller to hold.
Must be called exactly once per turn, before runtime.run().
Sourcepub async fn kill_mcp_children(&mut self)
pub async fn kill_mcp_children(&mut self)
Kill all tracked MCP child processes using the graceful shutdown protocol (SIGTERM → timeout → SIGKILL). Called during session/close, session/load, session/resume, and client disconnect cleanup.