Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions docs/ai-python/content/docs/reference/ai.agents/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,25 @@ forwarded `PartialToolCallResult` events.
- `BoundToolCall`
- `ToolCallCallable`

## GatedToolCall
`BoundToolCall.fn` is always the underlying `AgentTool` function.
`BoundToolCall.wrap` returns a new bound call with the same `fn` and a wrapper
that returns a `ToolCallResult` inside argument validation and exception
handling:

```python
def wrap(call: ai.agents.BoundToolCall, inner):
async def wrapped(**kwargs):
print(call.name)
return await inner(**kwargs)

return wrapped

`GatedToolCall` wraps a tool call that requires approval or another gate before
execution.

Use it in custom agent loops when you need to delay or externally approve a
scheduled tool call.
wrapped_call = tool_call.wrap(wrap)
```

## GatedToolCall

`GatedToolCall` remains available for compatibility. It is a
`BoundToolCall` subclass that uses the wrapper mechanism to apply the built-in
approval gate before invoking the wrapped call.
4 changes: 2 additions & 2 deletions docs/ai-python/content/docs/reference/ai/agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ agent.tools

## resolve

`Agent.resolve` converts model tool-call parts into executable `ToolCall`
`Agent.resolve` converts model tool-call parts into executable `BoundToolCall`
objects. Use it when implementing a custom `Agent.loop`:

```python
Expand All @@ -34,7 +34,7 @@ class CustomAgent(ai.Agent):

Resolution performs tool-name lookup and argument validation, and applies
approval gates and cached replay results. Pass a sequence of tool-call parts
to resolve to get a list of executable calls.
to resolve to get a list of executable `BoundToolCall` objects.

## Current execution context

Expand Down
4 changes: 2 additions & 2 deletions docs/ai-python/content/docs/reference/ai/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ Useful methods:

- `keep_running()`: Return `True` while the last message still needs work.
- `resolve(tool_call)`: Convert model tool call parts into executable
`ToolCall` objects.
`BoundToolCall` objects.
- `add(message)`: Append messages to history.

### ToolCall

`ToolCall` is the executable runtime object produced by `Agent.resolve`.
`BoundToolCall` is the executable runtime object produced by `Agent.resolve`.
`Context.resolve` remains available for backward compatibility.

```python
Expand Down
Loading
Loading