Tool Calling
Tool execution is the core functionality of Agent Actions that allows you to perform actions on third-party applications using connected accounts. Tools abstract complex API operations into simple, consistent function calls.
What is tool execution?
Section titled “What is tool execution?”Tool execution in Agent Actions enables you to:
- Perform actions on third-party applications via connected accounts
- Execute operations like sending emails, creating calendar events, or fetching data on-behalf-of users
- Handle authentication automatically using connected account tokens
Tool execution workflow
Section titled “Tool execution workflow”- Identify the tool you want to execute (e.g.,
send_email
,create_event
) - Select connected account that has the required permissions
- Prepare parameters needed for the tool execution
- Execute the tool using the Agent Actions API
- Handle the response and any errors that occur
Direct tool execution
Section titled “Direct tool execution”Using Scalekit SDK, you can execute any action on behalf of a user using the following parameters:
- user context
- tool_name
- tool_input_parameters
# Fetch recent emailstool_response = agent_connect.tools.execute( # connected_account gives the user context connected_account_id=connected_account.id, # tool name to execute tool='gmail_fetch_mails', # tool input parameters parameters={ 'query': 'is:unread', 'max_results': 5 })
print(f'Recent emails: {tool_response.result}')
Tool Schema Inspection
Section titled “Tool Schema Inspection”To execute the tool calls effectively, you first need to understand the required parameters for any given tool. You can inspect the tool schema by fetching the tool metadata information using the scalekit sdk.
tool_schema = agent_connect.tools.get_schema(tool='gmail_fetch_emails')# tool_schema has description, input schema and output schema