Add agent state methods to CustomToolContext and fix abort signature
CustomToolContext now has: - isIdle() - check if agent is streaming - hasQueuedMessages() - check if user has queued messages - abort() - abort current operation (fire-and-forget) Changed abort() signature from Promise<void> to void in both HookContext and CustomToolContext. The abort is fire-and-forget: it calls session.abort() without awaiting, so the abort signal is set immediately while waitForIdle() runs in the background. Fixes #388
This commit is contained in:
@@ -76,7 +76,10 @@ execute(toolCallId, params, signal, onUpdate)
|
||||
execute(toolCallId, params, onUpdate, ctx, signal?)
|
||||
```
|
||||
|
||||
The new `ctx: CustomToolContext` provides `sessionManager`, `modelRegistry`, and `model`.
|
||||
The new `ctx: CustomToolContext` provides `sessionManager`, `modelRegistry`, `model`, and agent state methods:
|
||||
- `ctx.isIdle()` - check if agent is streaming
|
||||
- `ctx.hasQueuedMessages()` - check if user has queued messages (skip interactive prompts)
|
||||
- `ctx.abort()` - abort current operation (fire-and-forget)
|
||||
|
||||
**Session event changes:**
|
||||
- `CustomToolSessionEvent` now only has `reason` and `previousSessionFile`
|
||||
|
||||
Reference in New Issue
Block a user