You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"
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.
The ID of the mode to switch to. Must be one of the modes listed in
96
+
`availableModes`
97
+
</ParamField>
98
+
99
+
### From the Agent
100
+
101
+
The Agent can also change its own mode and let the Client know by sending the `current_mode_update` session notification:
102
+
103
+
```json
104
+
{
105
+
"jsonrpc": "2.0",
106
+
"method": "session/update",
107
+
"params": {
108
+
"sessionId": "sess_abc123def456",
109
+
"update": {
110
+
"sessionUpdate": "current_mode_update",
111
+
"modeId": "code"
112
+
}
113
+
}
114
+
}
115
+
```
116
+
117
+
#### Exiting plan modes
118
+
119
+
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.
120
+
121
+
This "switch mode" tool will usually request permission before running, which it can do just like any other tool:
122
+
123
+
```json
124
+
{
125
+
"jsonrpc": "2.0",
126
+
"id": 3,
127
+
"method": "session/request_permission",
128
+
"params": {
129
+
"sessionId": "sess_abc123def456",
130
+
"toolCall": {
131
+
"toolCallId": "call_switch_mode_001",
132
+
"title": "Ready for implementation",
133
+
"kind": "switch_mode",
134
+
"status": "pending",
135
+
"content": [
136
+
{
137
+
"type": "text",
138
+
"text": "## Implementation Plan..."
139
+
}
140
+
]
141
+
},
142
+
"options": [
143
+
{
144
+
"optionId": "code",
145
+
"name": "Yes, and auto-accept all actions",
146
+
"kind": "allow_always"
147
+
},
148
+
{
149
+
"optionId": "ask",
150
+
"name": "Yes, and manually accept actions",
151
+
"kind": "allow_once"
152
+
},
153
+
{
154
+
"optionId": "reject",
155
+
"name": "No, stay in architect mode",
156
+
"kind": "reject_once"
157
+
}
158
+
]
159
+
}
160
+
}
161
+
```
162
+
163
+
When an option is chosen, the tool runs, setting the mode and sending the `current_mode_update` notification mentioned above.
0 commit comments