Skip to content

Commit 8a8e2a8

Browse files
committed
docs(agent): update steering docs for deferred tool execution closes badlogic#2330
1 parent 16a010f commit 8a8e2a8

File tree

8 files changed

+21
-19
lines changed

8 files changed

+21
-19
lines changed

packages/agent/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ agent.clearAllQueues();
310310

311311
Use clearSteeringQueue, clearFollowUpQueue, or clearAllQueues to drop queued messages.
312312

313-
When steering messages are detected after a tool completes:
314-
1. Remaining tools are skipped with error results
313+
When steering messages are detected after a turn completes:
314+
1. All tool calls from the current assistant message have already finished
315315
2. Steering messages are injected
316-
3. LLM responds to the interruption
316+
3. The LLM responds on the next turn
317317

318318
Follow-up messages are checked only when there are no more tool calls and no steering messages. If any are queued, they are injected and another turn runs.
319319

packages/agent/src/agent.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ export class Agent {
304304
}
305305

306306
/**
307-
* Queue a steering message to interrupt the agent mid-run.
308-
* Delivered after current tool execution, skips remaining tools.
307+
* Queue a steering message while the agent is running.
308+
* Delivered after the current assistant turn finishes executing its tool calls,
309+
* before the next LLM call.
309310
*/
310311
steer(m: AgentMessage) {
311312
this.steeringQueue.push(m);

packages/agent/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
159159
/**
160160
* Returns steering messages to inject into the conversation mid-run.
161161
*
162-
* Called after each tool execution to check for user interruptions.
163-
* If messages are returned, remaining tool calls are skipped and
164-
* these messages are added to the context before the next LLM call.
162+
* Called after the current assistant turn finishes executing its tool calls.
163+
* If messages are returned, they are added to the context before the next LLM call.
164+
* Tool calls from the current assistant message are not skipped.
165165
*
166166
* Use this for "steering" the agent while it's working.
167167
*

packages/coding-agent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ See `/hotkeys` for the full list. Customize via `~/.pi/agent/keybindings.json`.
181181

182182
Submit messages while the agent is working:
183183

184-
- **Enter** queues a *steering* message, delivered after current tool execution (interrupts remaining tools)
184+
- **Enter** queues a *steering* message, delivered after the current assistant turn finishes executing its tool calls
185185
- **Alt+Enter** queues a *follow-up* message, delivered only after the agent finishes all work
186186
- **Escape** aborts and restores queued messages to editor
187187
- **Alt+Up** retrieves queued messages back to editor

packages/coding-agent/docs/extensions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ pi.sendMessage({
999999

10001000
**Options:**
10011001
- `deliverAs` - Delivery mode:
1002-
- `"steer"` (default) - Interrupts streaming. Delivered after current tool finishes, remaining tools skipped.
1002+
- `"steer"` (default) - Queues the message while streaming. Delivered after the current assistant turn finishes executing its tool calls, before the next LLM call.
10031003
- `"followUp"` - Waits for agent to finish. Delivered only when agent has no more tool calls.
10041004
- `"nextTurn"` - Queued for next user prompt. Does not interrupt or trigger anything.
10051005
- `triggerTurn: true` - If agent is idle, trigger an LLM response immediately. Only applies to `"steer"` and `"followUp"` modes (ignored for `"nextTurn"`).
@@ -1025,7 +1025,7 @@ pi.sendUserMessage("And then summarize", { deliverAs: "followUp" });
10251025

10261026
**Options:**
10271027
- `deliverAs` - Required when agent is streaming:
1028-
- `"steer"` - Interrupts after current tool, remaining tools skipped
1028+
- `"steer"` - Queues the message for delivery after the current assistant turn finishes executing its tool calls
10291029
- `"followUp"` - Waits for agent to finish all tools
10301030

10311031
When not streaming, the message is sent immediately and triggers a new turn. When streaming without `deliverAs`, throws an error.

packages/coding-agent/docs/rpc.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ With images:
5858
{"type": "prompt", "message": "New instruction", "streamingBehavior": "steer"}
5959
```
6060

61-
- `"steer"`: Interrupt the agent mid-run. Message is delivered after current tool execution, remaining tools are skipped.
61+
- `"steer"`: Queue the message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call.
6262
- `"followUp"`: Wait until the agent finishes. Message is delivered only when agent stops.
6363

6464
If the agent is streaming and no `streamingBehavior` is specified, the command returns an error.
@@ -76,7 +76,7 @@ The `images` field is optional. Each image uses `ImageContent` format: `{"type":
7676

7777
#### steer
7878

79-
Queue a steering message to interrupt the agent mid-run. Delivered after current tool execution, remaining tools are skipped. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
79+
Queue a steering message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
8080

8181
```json
8282
{"type": "steer", "message": "Stop and do this instead"}
@@ -321,8 +321,8 @@ Control how steering messages (from `steer`) are delivered.
321321
```
322322

323323
Modes:
324-
- `"all"`: Deliver all steering messages at the next interruption point
325-
- `"one-at-a-time"`: Deliver one steering message per interruption (default)
324+
- `"all"`: Deliver all steering messages after the current assistant turn finishes executing its tool calls
325+
- `"one-at-a-time"`: Deliver one steering message per completed assistant turn (default)
326326

327327
Response:
328328
```json

packages/coding-agent/docs/sdk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ interface AgentSession {
7878
prompt(text: string, options?: PromptOptions): Promise<void>;
7979

8080
// Queue messages during streaming
81-
steer(text: string): Promise<void>; // Interrupt: delivered after current tool, skips remaining
81+
steer(text: string): Promise<void>; // Queue for delivery after the current assistant turn finishes its tool calls
8282
followUp(text: string): Promise<void>; // Wait: delivered only when agent finishes
8383

8484
// Subscribe to events (returns unsubscribe function)
@@ -150,7 +150,7 @@ await session.prompt("After you're done, also check X", { streamingBehavior: "fo
150150
For explicit queueing during streaming:
151151

152152
```typescript
153-
// Interrupt the agent (delivered after current tool, skips remaining tools)
153+
// Queue a steering message for delivery after the current assistant turn finishes its tool calls
154154
await session.steer("New instruction");
155155

156156
// Wait for agent to finish (delivered only when agent stops)

packages/coding-agent/src/core/agent-session.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,9 @@ export class AgentSession {
10661066
}
10671067

10681068
/**
1069-
* Queue a steering message to interrupt the agent mid-run.
1070-
* Delivered after current tool execution, skips remaining tools.
1069+
* Queue a steering message while the agent is running.
1070+
* Delivered after the current assistant turn finishes executing its tool calls,
1071+
* before the next LLM call.
10711072
* Expands skill commands and prompt templates. Errors on extension commands.
10721073
* @param images Optional image attachments to include with the message
10731074
* @throws Error if text is an extension command

0 commit comments

Comments
 (0)