Module 08: Permissions
Handle permission requests from agents on the client side.What You’ll Learn
- Registering a
requestPermissionHandler PermissionOptionandPermissionOptionKindtypes- Permission outcomes: selected vs cancelled
The Code
When an agent wants to perform a sensitive operation (like writing a file or running a command), it can ask the client for permission first. The client registers arequestPermissionHandler that receives the request details and a list of options (allow once, allow always, reject). Your handler decides which option to select — typically by showing a dialog to the user:
Permission Option Kinds
The agent sends a
RequestPermissionRequest containing the tool call details and a list of options. The client presents choices to the user and returns the selected option ID. This completes the bidirectional request flow (with Module 07 for files).
Source Code
View on GitHubRunning the Example
Requires the Grok CLI on yourPATH, signed in once with grok login. The module launches it as grok agent stdio; no API key is needed.
The prompt asks Grok to create hello.txt. In Grok’s default (ask) mode it sends session/request_permission before the write, and the client prints the options and reads your choice. Grok also reads Claude Code’s settings: if ~/.claude/settings.json sets "defaultMode" to "auto" or "acceptEdits", Grok writes the file without asking, and no permission request appears.