The custom tools API has been restructured to mirror the hooks pattern with a context object.
Type renames:
CustomAgentTool → CustomTool
ToolAPI → CustomToolAPI
ToolContext → CustomToolContext
ToolSessionEvent → CustomToolSessionEvent
Execute signature changed:
// Before (v0.30.2)
execute(toolCallId, params, signal, onUpdate)
// After
execute(toolCallId, params, onUpdate, ctx, signal?)
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
- Session entries are no longer in the event. Use
ctx.sessionManager.getBranch() or ctx.sessionManager.getEntries() to reconstruct state
- Reasons:
"start" | "switch" | "branch" | "tree" | "shutdown" (no separate "new" reason; /new triggers "switch")
dispose() method removed. Use onSession with reason: "shutdown" for cleanup
See docs/custom-tools.md and examples/custom-tools/ for the current API.