|
| 1 | +--- |
| 2 | +title: "Slash Commands" |
| 3 | +description: "Advertise available slash commands to clients" |
| 4 | +--- |
| 5 | + |
| 6 | +Agents can advertise a set of slash commands that users can invoke. These commands provide quick access to specific agent capabilities and workflows. Commands are run as part of regular [prompt](./prompt-turn) requests where the Client includes the command text in the prompt. |
| 7 | + |
| 8 | +## Advertising commands |
| 9 | + |
| 10 | +After creating a session, the Agent **MAY** send a list of available commands via the `available_commands_update` session notification: |
| 11 | + |
| 12 | +```json |
| 13 | +{ |
| 14 | + "jsonrpc": "2.0", |
| 15 | + "method": "session/update", |
| 16 | + "params": { |
| 17 | + "sessionId": "sess_abc123def456", |
| 18 | + "update": { |
| 19 | + "sessionUpdate": "available_commands_update", |
| 20 | + "availableCommands": [ |
| 21 | + { |
| 22 | + "name": "web", |
| 23 | + "description": "Search the web for information", |
| 24 | + "input": { |
| 25 | + "hint": "query to search for" |
| 26 | + } |
| 27 | + }, |
| 28 | + { |
| 29 | + "name": "test", |
| 30 | + "description": "Run tests for the current project" |
| 31 | + }, |
| 32 | + { |
| 33 | + "name": "plan", |
| 34 | + "description": "Create a detailed implementation plan", |
| 35 | + "input": { |
| 36 | + "hint": "description of what to plan" |
| 37 | + } |
| 38 | + } |
| 39 | + ] |
| 40 | + } |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +<ResponseField name="availableCommands" type="AvailableCommand[]"> |
| 46 | + The list of commands available in this session |
| 47 | +</ResponseField> |
| 48 | + |
| 49 | +### AvailableCommand |
| 50 | + |
| 51 | +<ResponseField name="name" type="string" required> |
| 52 | + The command name (e.g., "web", "test", "plan") |
| 53 | +</ResponseField> |
| 54 | + |
| 55 | +<ResponseField name="description" type="string" required> |
| 56 | + Human-readable description of what the command does |
| 57 | +</ResponseField> |
| 58 | + |
| 59 | +<ResponseField name="input" type="AvailableCommandInput"> |
| 60 | + Optional input specification for the command |
| 61 | +</ResponseField> |
| 62 | + |
| 63 | +### AvailableCommandInput |
| 64 | + |
| 65 | +Currently supports unstructured text input: |
| 66 | + |
| 67 | +<ResponseField name="hint" type="string" required> |
| 68 | + A hint to display when the input hasn't been provided yet |
| 69 | +</ResponseField> |
| 70 | + |
| 71 | +## Dynamic updates |
| 72 | + |
| 73 | +The Agent can update the list of available commands at any time during a session by sending another `available_commands_update` notification. This allows commands to be added based on context, removed when no longer relevant, or modified with updated descriptions. |
| 74 | + |
| 75 | +## Running commands |
| 76 | + |
| 77 | +Commands are included as regular user messages in prompt requests: |
| 78 | + |
| 79 | +```json |
| 80 | +{ |
| 81 | + "jsonrpc": "2.0", |
| 82 | + "id": 3, |
| 83 | + "method": "session/prompt", |
| 84 | + "params": { |
| 85 | + "sessionId": "sess_abc123def456", |
| 86 | + "prompt": [ |
| 87 | + { |
| 88 | + "type": "text", |
| 89 | + "text": "/web agent client protocol" |
| 90 | + } |
| 91 | + ] |
| 92 | + } |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +The Agent recognizes the command prefix and processes it accordingly. Commands may be accompanied by any other user message content types (images, audio, etc.) in the same prompt array. |
0 commit comments