Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
Joined May 2026
258 Following    224 Followers
# Useful but Little-Known Features of Claude Agent SDK ๐ŸŒ Need to change permissions mid-session? You can dynamically switch permission modes during streaming! Claude Agent SDK lets you call `set_permission_mode()` to instantly change the permission mode while a session is running. ๐Ÿ“Œ Title: Dynamic Permission Mode Changes During Streaming ๐Ÿ”— URL: ๐Ÿงฉ Overview Using `set_permission_mode()` (Python) or `setPermissionMode()` (TypeScript), you can change the permission mode in real-time during an active session. The new mode takes effect immediately for all subsequent tool requests. This enables progressive trust workflows where you start restrictive and loosen permissions as confidence builds, for example switching from `default` to `acceptEdits` after reviewing Claude's initial approach. ๐Ÿ›  How to Use ```python # Python - progressively relaxing permissions import asyncio from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions async def main(): async with ClaudeSDKClient( options=ClaudeAgentOptions( permission_mode="default", # Start in default mode ) ) as client: await client.query("Refactor this code") # After reviewing the approach, allow edits await client.set_permission_mode("acceptEdits") async for message in client.receive_response(): if hasattr(message, "result"): print(message.result) ``` ```typescript // TypeScript const q = query({ prompt: "Refactor this code", options: { permissionMode: "default" } }); // After reviewing the approach, allow edits await q.setPermissionMode("acceptEdits"); for await (const message of q) { if ("result" in message) console.log(message.result); } ``` ๐Ÿ— Integration into Production Systems - Implement "plan, review, then acceptEdits" workflows for safe step-by-step automation - Build interactive apps that progressively expand permissions based on user trust and task progress - Use as a "fallback" pattern to tighten permissions when errors are detected - Integrate with monitoring systems to automatically switch to restrictive modes on anomaly detection ๐Ÿ’ก Use Cases ๐Ÿ” Interactive workflows that grant edit permissions only after code review approval ๐Ÿ“ˆ Progressive automation that expands permissions as the task advances ๐Ÿ›ก Defensive agents that instantly switch to restrictive mode upon detecting anomalies โš ๏ธ Caveats - The new mode takes effect immediately, so be careful about the timing of the switch - Mode changes are only effective within the current session - Switching to `bypassPermissions` or `auto` mode will be inherited by subagents โœจ Dynamic permission changes enable "start safe, flex as needed." Build progressive trust workflows to get the best of both safety and productivity! #ClaudeAgentSDK# #AIAgent#
Show more