|
1 | 1 | --- |
2 | 2 | title: "Approve Tool Calls" |
3 | | -description: "Have tool calls approved by the client before execution" |
| 3 | +description: "Have tool calls approved by the user before execution" |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | Many agent frameworks support the ability to request user approval before executing certain actions. This is especially useful when an agent is calling external tools that may have significant effects or costs associated with their usage. |
7 | 7 |
|
8 | | -The `Tool Call Extension` provides a mechanism for implementing this functionality over A2A connection. |
| 8 | +The Tool Call extension provides a mechanism for implementing this functionality over A2A connection. |
9 | 9 |
|
10 | | -## Usage with BeeAI Framework |
| 10 | +## Usage |
11 | 11 |
|
12 | 12 | <Steps> |
13 | | -<Step title="Install the BeeAI Framework dependency"> |
14 | | -Make sure `beeai-framework` is installed as a dependency in your project. |
15 | | -</Step> |
16 | | - |
17 | | -<Step title="Add extension to your agent"> |
18 | | - Inject the Tool Call extension into your agent function using the `Annotated` |
| 13 | +<Step title="Add Tool Call extension to your agent"> |
| 14 | + Inject the `ToolCallExtension` into your agent function using the `Annotated` |
19 | 15 | type hint. |
20 | 16 | </Step> |
21 | 17 |
|
22 | | -<Step title="Implement the handler for AskPermissionRequirement"> |
23 | | - Use `request_tool_call_approval()` to request tool call approval from the user through A2A. |
| 18 | +<Step title="Implement the approval logic in your agent"> |
| 19 | + Use `request_tool_call_approval()` method to request tool call approval from the A2A client side. |
24 | 20 | </Step> |
25 | 21 | </Steps> |
26 | 22 |
|
27 | 23 | ## Basic Example |
28 | 24 |
|
29 | | -Here's how to use this extension with the BeeAI Framework to request user approval before executing a tool call: |
| 25 | +Here's how to use this extension with the [BeeAI Framework](https://framework.beeai.dev/modules/agents/requirement-agent#ask-permission-requirement) to request user approval before executing a tool call: |
30 | 26 |
|
31 | 27 | ```python |
32 | 28 | from typing import Annotated, Any |
@@ -62,6 +58,7 @@ async def tool_call_agent( |
62 | 58 | async def handler(tool: Tool, input: dict[str, Any]) -> bool: |
63 | 59 | try: |
64 | 60 | await mcp_tool_call.request_tool_call_approval( |
| 61 | + # using MCP Tool data model as intermediary to simplify conversion |
65 | 62 | ToolCallRequest.from_mcp_tool(_tool_factory(tool), input=input), |
66 | 63 | context=context, |
67 | 64 | ) |
|
0 commit comments