Agentic.Protocol.ACP.Session
(agentic v0.2.2)
Copy Markdown
ACP session lifecycle management.
Manages the full ACP connection lifecycle:
initialize-- negotiate protocol version and capabilitiesauthenticate-- if agent requires authenticationsession/new-- create a new conversation sessionsession/prompt-- send user messages, collect streaming updatessession/cancel-- cancel an ongoing prompt turn- Cleanup -- close connection gracefully
Usage
{:ok, session} = Agentic.Protocol.ACP.Session.connect(
client: acp_client,
workspace: "/path/to/project",
permission_policy: :ask
)
{:ok, response, session} = Agentic.Protocol.ACP.Session.prompt(
session,
[%{"type" => "text", "text" => "Hello"}]
)
:ok = Agentic.Protocol.ACP.Session.cancel(session)
:ok = Agentic.Protocol.ACP.Session.close(session)
Summary
Functions
Check if the agent supports session loading.
Cancel the current prompt turn.
Close the session and stop the client.
Connect to an ACP agent: initialize, authenticate (if needed), create session.
Load an existing session by ID.
Send a prompt to the agent and collect the response.
Switch the agent operating mode.
Check if the agent supports audio input.
Check if the agent supports image input.
Types
@type session() :: %Agentic.Protocol.ACP.Session{ agent_capabilities: map() | nil, agent_info: map() | nil, client: pid(), mcp_servers: [map()], permission_policy: atom(), prompt_accumulator: String.t(), protocol_version: pos_integer() | nil, session_id: String.t() | nil, updates: [map()], workspace: String.t() }
Functions
Check if the agent supports session loading.
Cancel the current prompt turn.
Close the session and stop the client.
Connect to an ACP agent: initialize, authenticate (if needed), create session.
Options
:client- ACP Client pid (required):workspace- Working directory for the session (required):permission_policy-:ask,:allow_all, or:deny_all(default:ask):mcp_servers- List of MCP server configs to forward (default[]):client_info- Override client info sent during initialize:client_capabilities- Override client capabilities
Load an existing session by ID.
Only works if the agent advertised loadSession: true during initialize.
@spec prompt(session(), [Agentic.Protocol.ACP.Types.content_block()], keyword()) :: {:ok, map(), session()} | {:error, term()}
Send a prompt to the agent and collect the response.
Returns {:ok, response, session} where response contains:
:content- accumulated text content:tool_calls- list of tool calls made during the turn:stop_reason- why the agent stopped:updates- all raw session/update notifications received
Switch the agent operating mode.
Check if the agent supports audio input.
Check if the agent supports image input.