Follow Discord
Sweep 03 Nov 2026 · 22:27Z Build v2.1.318 536 read Stable v2.1.311 Latest v2.1.318 Next v2.1.318 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · claude-code

Configure permissions changedagent-sdk/permissions

Nearest release: v2.1.312, published an hour after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Upstream edited this page at 27 Oct 2026 16:49 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 30 Oct 2026 18:07 UTC.

Upstream edited
Recorded here
Lines+95added
Lines−95removed
From line 159 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits32to this page, all time

The whole hunk

from line 159, old and new numbered
/
lines
from line 159
159159 
160160You can set the permission mode once when starting a query, or change it dynamically while the session is active.
161161 
162**At query time**
162> [tab] At query time
163>
164> Pass `permission_mode` (Python) or `permissionMode` (TypeScript) when creating a query.
165>
166> ```python Python theme={null}
167> import asyncio
168> from claude_agent_sdk import query, ClaudeAgentOptions
169>
170>
171> async def main():
172> async for message in query(
173> prompt="Help me refactor this code",
174> options=ClaudeAgentOptions(
175> permission_mode="default", # Set the mode here
176> ),
177> ):
178> if hasattr(message, "result"):
179> print(message.result)
180>
181>
182> asyncio.run(main())
183> ```
184>
185> ```typescript TypeScript theme={null}
186> import { query } from "@anthropic-ai/claude-agent-sdk";
187>
188> async function main() {
189> for await (const message of query({
190> prompt: "Help me refactor this code",
191> options: {
192> permissionMode: "default" // Set the mode here
193> }
194> })) {
195> if ("result" in message) {
196> console.log(message.result);
197> }
198> }
199> }
200>
201> main();
202> ```
163203 
164Pass `permission_mode` (Python) or `permissionMode` (TypeScript) when creating a query.
165 
166```python Python theme={null}
167import asyncio
168from claude_agent_sdk import query, ClaudeAgentOptions
169 
170 
171async def main():
172 async for message in query(
173 prompt="Help me refactor this code",
174 options=ClaudeAgentOptions(
175 permission_mode="default", # Set the mode here
176 ),
177 ):
178 if hasattr(message, "result"):
179 print(message.result)
180 
181 
182asyncio.run(main())
183```
184 
185```typescript TypeScript theme={null}
186import { query } from "@anthropic-ai/claude-agent-sdk";
187 
188async function main() {
189 for await (const message of query({
190 prompt: "Help me refactor this code",
191 options: {
192 permissionMode: "default" // Set the mode here
193 }
194 })) {
195 if ("result" in message) {
196 console.log(message.result);
197 }
198 }
199}
200 
201main();
202```
203 
204**During streaming**
205 
206Call `set_permission_mode()` (Python) or `setPermissionMode()` (TypeScript) to change the mode mid-session. The new mode takes effect immediately for all subsequent tool requests. This lets you start restrictive and loosen permissions as trust builds, for example switching to `acceptEdits` after reviewing Claude's initial approach.
207 
208```python Python theme={null}
209import asyncio
210from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
211 
212 
213async def main():
214 async with ClaudeSDKClient(
215 options=ClaudeAgentOptions(
216 permission_mode="default", # Start in default mode
217 )
218 ) as client:
219 await client.query("Help me refactor this code")
220 
221 # Change mode dynamically mid-session
222 await client.set_permission_mode("acceptEdits")
223 
224 # Process messages with the new permission mode
225 async for message in client.receive_response():
226 if hasattr(message, "result"):
227 print(message.result)
228 
229 
230asyncio.run(main())
231```
232 
233```typescript TypeScript theme={null}
234import { query } from "@anthropic-ai/claude-agent-sdk";
235 
236async function main() {
237 const q = query({
238 prompt: "Help me refactor this code",
239 options: {
240 permissionMode: "default" // Start in default mode
241 }
242 });
243 
244 // Change mode dynamically mid-session
245 await q.setPermissionMode("acceptEdits");
246 
247 // Process messages with the new permission mode
248 for await (const message of q) {
249 if ("result" in message) {
250 console.log(message.result);
251 }
252 }
253}
254 
255main();
256```
204> [tab] During streaming
205>
206> Call `set_permission_mode()` (Python) or `setPermissionMode()` (TypeScript) to change the mode mid-session. The new mode takes effect immediately for all subsequent tool requests. This lets you start restrictive and loosen permissions as trust builds, for example switching to `acceptEdits` after reviewing Claude's initial approach.
207>
208> ```python Python theme={null}
209> import asyncio
210> from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
211>
212>
213> async def main():
214> async with ClaudeSDKClient(
215> options=ClaudeAgentOptions(
216> permission_mode="default", # Start in default mode
217> )
218> ) as client:
219> await client.query("Help me refactor this code")
220>
221> # Change mode dynamically mid-session
222> await client.set_permission_mode("acceptEdits")
223>
224> # Process messages with the new permission mode
225> async for message in client.receive_response():
226> if hasattr(message, "result"):
227> print(message.result)
228>
229>
230> asyncio.run(main())
231> ```
232>
233> ```typescript TypeScript theme={null}
234> import { query } from "@anthropic-ai/claude-agent-sdk";
235>
236> async function main() {
237> const q = query({
238> prompt: "Help me refactor this code",
239> options: {
240> permissionMode: "default" // Start in default mode
241> }
242> });
243>
244> // Change mode dynamically mid-session
245> await q.setPermissionMode("acceptEdits");
246>
247> // Process messages with the new permission mode
248> for await (const message of q) {
249> if ("result" in message) {
250> console.log(message.result);
251> }
252> }
253> }
254>
255> main();
256> ```
257257 
258258### Mode details
259259 
Feedback