Skip to content

Commit 659687a

Browse files
committed
Stabilize session modes
1 parent cfaa0a5 commit 659687a

10 files changed

Lines changed: 317 additions & 155 deletions

File tree

docs/docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"protocol/file-system",
5959
"protocol/terminals",
6060
"protocol/agent-plan",
61+
"protocol/session-modes",
6162
"protocol/extensibility",
6263
"protocol/schema"
6364
]

docs/protocol/schema.mdx

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ Response from loading an existing session.
234234
Extension point for implementations
235235
</ResponseField>
236236
<ResponseField name="modes" type={<><span><a href="#sessionmodestate">SessionModeState</a></span><span> | null</span></>} >
237-
**UNSTABLE**
237+
Initial mode state if supported by the Agent
238238

239-
This field is not part of the spec, and may be removed or changed at any point.
239+
See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
240240

241241
</ResponseField>
242242

@@ -302,9 +302,9 @@ See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol
302302
Extension point for implementations
303303
</ResponseField>
304304
<ResponseField name="modes" type={<><span><a href="#sessionmodestate">SessionModeState</a></span><span> | null</span></>} >
305-
**UNSTABLE**
305+
Initial mode state if supported by the Agent
306306

307-
This field is not part of the spec, and may be removed or changed at any point.
307+
See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
308308

309309
</ResponseField>
310310
<ResponseField name="sessionId" type={<a href="#sessionid">SessionId</a>} required>
@@ -386,6 +386,49 @@ See protocol docs: [Check for Completion](https://agentclientprotocol.com/protoc
386386
Indicates why the agent stopped processing the turn.
387387
</ResponseField>
388388

389+
<a id="session-set_mode"></a>
390+
### <span class="font-mono">session/set_mode</span>
391+
392+
**UNSTABLE**
393+
394+
This method is not part of the spec, and may be removed or changed at any point.
395+
396+
#### <span class="font-mono">SetSessionModeRequest</span>
397+
398+
Request parameters for setting a session mode.
399+
400+
**Type:** Object
401+
402+
**Properties:**
403+
404+
<ResponseField name="_meta" type={"object"}>
405+
Extension point for implementations
406+
</ResponseField>
407+
<ResponseField
408+
name="modeId"
409+
type={<a href="#sessionmodeid">SessionModeId</a>}
410+
required
411+
>
412+
The ID of the mode to set.
413+
</ResponseField>
414+
<ResponseField
415+
name="sessionId"
416+
type={<a href="#sessionid">SessionId</a>}
417+
required
418+
>
419+
The ID of the session to set the mode for.
420+
</ResponseField>
421+
422+
#### <span class="font-mono">SetSessionModeResponse</span>
423+
424+
Response to `session/set_mode` method.
425+
426+
**Type:** Object
427+
428+
**Properties:**
429+
430+
<ResponseField name="meta" type={"object"}></ResponseField>
431+
389432
## Client
390433

391434
Defines the interface that ACP-compliant clients must implement.
@@ -1885,9 +1928,9 @@ See protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session
18851928

18861929
## <span class="font-mono">SessionMode</span>
18871930

1888-
**UNSTABLE**
1931+
A mode the agent can operate in.
18891932

1890-
This type is not part of the spec, and may be removed or changed at any point.
1933+
See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
18911934

18921935
**Type:** Object
18931936

@@ -1906,17 +1949,13 @@ This type is not part of the spec, and may be removed or changed at any point.
19061949

19071950
## <span class="font-mono">SessionModeId</span>
19081951

1909-
**UNSTABLE**
1910-
1911-
This type is not part of the spec, and may be removed or changed at any point.
1952+
Unique identifier for a Session Mode.
19121953

19131954
**Type:** `string`
19141955

19151956
## <span class="font-mono">SessionModeState</span>
19161957

1917-
**UNSTABLE**
1918-
1919-
This type is not part of the spec, and may be removed or changed at any point.
1958+
The set of modes and the one currently active.
19201959

19211960
**Type:** Object
19221961

@@ -1936,12 +1975,16 @@ This type is not part of the spec, and may be removed or changed at any point.
19361975
</>
19371976
}
19381977
required
1939-
></ResponseField>
1978+
>
1979+
The set of modes that the Agent can operate in
1980+
</ResponseField>
19401981
<ResponseField
19411982
name="currentModeId"
19421983
type={<a href="#sessionmodeid">SessionModeId</a>}
19431984
required
1944-
></ResponseField>
1985+
>
1986+
The current mode the Agent is in.
1987+
</ResponseField>
19451988

19461989
## <span class="font-mono">SessionUpdate</span>
19471990

@@ -2184,18 +2227,6 @@ The current mode of the session has changed
21842227
</Expandable>
21852228
</ResponseField>
21862229

2187-
## <span class="font-mono">SetSessionModeResponse</span>
2188-
2189-
**UNSTABLE**
2190-
2191-
This type is not part of the spec, and may be removed or changed at any point.
2192-
2193-
**Type:** Object
2194-
2195-
**Properties:**
2196-
2197-
<ResponseField name="meta" type={"object"}></ResponseField>
2198-
21992230
## <span class="font-mono">StopReason</span>
22002231

22012232
Reasons why an agent stops processing a prompt turn.
@@ -2576,10 +2607,7 @@ See protocol docs: [Creating](https://agentclientprotocol.com/protocol/tool-call
25762607
<ResponseField name="fetch">Retrieving external data.</ResponseField>
25772608

25782609
<ResponseField name="switch_mode">
2579-
**UNSTABLE**
2580-
2581-
This tool kind is not part of the spec and may be removed at any point.
2582-
2610+
Switching the current session mode.
25832611
</ResponseField>
25842612

25852613
<ResponseField name="other">Other tool types (default).</ResponseField>

docs/protocol/session-modes.mdx

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
title: "Session Modes"
3+
description: "How agents can operate in different modes"
4+
---
5+
6+
Agents can provide a set of modes they can operate in. Modes often affect the system prompts used, the availability of tools, and whether they request permission before running.
7+
8+
## Initial state
9+
10+
During [Session Setup](./session-setup) the Agent **MAY** return a list of modes it can operate in and the currently active mode:
11+
12+
```json
13+
{
14+
"jsonrpc": "2.0",
15+
"id": 1,
16+
"result": {
17+
"sessionId": "sess_abc123def456",
18+
"modes": {
19+
"currentModeId": "ask",
20+
"availableModes": [
21+
{
22+
"id": "ask",
23+
"name": "Ask",
24+
"description": "Request permission before making any changes"
25+
},
26+
{
27+
"id": "architect",
28+
"name": "Architect",
29+
"description": "Design and plan software systems without implementation"
30+
},
31+
{
32+
"id": "code",
33+
"name": "Code",
34+
"description": "Write and modify code with full tool access"
35+
},
36+
]
37+
}
38+
}
39+
}
40+
```
41+
42+
<ResponseField name="modes" type="SessionModeState">
43+
The current mode state for the session
44+
</ResponseField>
45+
46+
### SessionModeState
47+
48+
<ResponseField name="currentModeId" type="SessionModeId" required>
49+
The ID of the mode that is currently active
50+
</ResponseField>
51+
52+
<ResponseField name="availableModes" type="SessionMode[]" required>
53+
The set of modes that the Agent can operate in
54+
</ResponseField>
55+
56+
### SessionMode
57+
58+
<ResponseField name="id" type="SessionModeId" required>
59+
Unique identifier for this mode
60+
</ResponseField>
61+
62+
<ResponseField name="name" type="string" required>
63+
Human-readable name of the mode
64+
</ResponseField>
65+
66+
<ResponseField name="description" type="string">
67+
Optional description providing more details about what this mode does
68+
</ResponseField>
69+
70+
## Setting the current mode
71+
72+
The current mode can be changed at any point during a session, whether the Agent is idle or generating a response.
73+
74+
### From the Client
75+
76+
Typically, Clients display the available modes to the user and allow them to change the current one, which they can do by calling the [`session/set_mode`](./schema#session%2Fset-mode) method.
77+
78+
```json
79+
{
80+
"jsonrpc": "2.0",
81+
"id": 2,
82+
"method": "session/set_mode",
83+
"params": {
84+
"sessionId": "sess_abc123def456",
85+
"modeId": "code"
86+
}
87+
}
88+
```
89+
90+
<ParamField path="sessionId" type="SessionId" required>
91+
The ID of the session to set the mode for
92+
</ParamField>
93+
94+
<ParamField path="modeId" type="SessionModeId" required>
95+
The ID of the mode to switch to. Must be one of the modes listed in `availableModes`
96+
</ParamField>
97+
98+
### From the Agent
99+
100+
The Agent can also change its own mode and let the Client know by sending the `current_mode_update` session notification:
101+
102+
```json
103+
{
104+
"jsonrpc": "2.0",
105+
"method": "session/update",
106+
"params": {
107+
"sessionId": "sess_abc123def456",
108+
"update": {
109+
"sessionUpdate": "current_mode_update",
110+
"modeId": "code"
111+
}
112+
}
113+
}
114+
```
115+
116+
#### Exiting plan modes
117+
118+
A common case where an Agent might switch modes is from within a special "exit mode" tool that can be provided to the language model during plan/architect modes. The language model can call this tool when it determines it's ready to start implementing a solution.
119+
120+
This "switch mode" tool will usually request permission before running, which it can do just like any other tool:
121+
122+
```json
123+
{
124+
"jsonrpc": "2.0",
125+
"id": 3,
126+
"method": "session/request_permission",
127+
"params": {
128+
"sessionId": "sess_abc123def456",
129+
"toolCall": {
130+
"toolCallId": "call_switch_mode_001",
131+
"title": "Ready for implementation",
132+
"kind": "switch_mode",
133+
"status": "pending",
134+
"content": [
135+
{
136+
"type": "text",
137+
"text": "## Implementation Plan..."
138+
}
139+
]
140+
},
141+
"options": [
142+
{
143+
"optionId": "code",
144+
"name": "Yes, and auto-accept all actions",
145+
"kind": "allow_always"
146+
},
147+
{
148+
"optionId": "ask",
149+
"name": "Yes, and manually accept actions",
150+
"kind": "allow_once"
151+
},
152+
{
153+
"optionId": "reject",
154+
"name": "No, stay in architect mode",
155+
"kind": "reject_once"
156+
}
157+
]
158+
}
159+
}
160+
```
161+
162+
When an option is chosen, the tool runs, setting the mode and sending the `current_mode_update` notification mentioned above.
163+
164+
<Card icon="shield-check" horizontal href="./tool-calls#requesting-permission">
165+
Learn more about permission requests
166+
</Card>

rust/acp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ impl Agent for ClientSideConnection {
211211
.map(|value| value.unwrap_or_default())
212212
}
213213

214-
#[cfg(feature = "unstable")]
215214
async fn set_session_mode(
216215
&self,
217216
arguments: SetSessionModeRequest,
@@ -619,7 +618,6 @@ impl Side for AgentSide {
619618
SESSION_LOAD_METHOD_NAME => serde_json::from_str(params.get())
620619
.map(ClientRequest::LoadSessionRequest)
621620
.map_err(Into::into),
622-
#[cfg(feature = "unstable")]
623621
SESSION_SET_MODE_METHOD_NAME => serde_json::from_str(params.get())
624622
.map(ClientRequest::SetSessionModeRequest)
625623
.map_err(Into::into),

0 commit comments

Comments
 (0)