mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(agent): allow blocked tool calls to terminate (#7715)
Closes #5998
This commit is contained in:
parent
1532c99943
commit
1eb988cfe8
7 changed files with 194 additions and 7 deletions
|
|
@ -762,7 +762,8 @@ Behavior guarantees:
|
|||
- Mutations to `event.input` affect the actual tool execution
|
||||
- Later `tool_call` handlers see mutations made by earlier handlers
|
||||
- No re-validation is performed after your mutation
|
||||
- Return values from `tool_call` only control blocking via `{ block: true, reason?: string }`
|
||||
- Return values from `tool_call` control blocking via `{ block: true, reason?: string, terminate?: boolean }`
|
||||
- `terminate` only applies to a blocked call; the agent stops early only when every finalized result in the batch is terminating
|
||||
|
||||
```typescript
|
||||
import { isToolCallEventType } from "@earendil-works/pi-coding-agent";
|
||||
|
|
@ -778,7 +779,7 @@ pi.on("tool_call", async (event, ctx) => {
|
|||
event.input.command = `source ~/.profile\n${event.input.command}`;
|
||||
|
||||
if (event.input.command.includes("rm -rf")) {
|
||||
return { block: true, reason: "Dangerous command" };
|
||||
return { block: true, reason: "Dangerous command", terminate: true };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue