CLOUD CONCEPT

Tool Calling

Tool calling is the mechanism by which an AI model requests that an application execute an external function or operation and return its result.

Cloud Concepts Hub →

What is Tool Calling

Tool calling connects a generative AI model to capabilities such as database queries, calculations, business APIs, and infrastructure operations. It enables agents to use current information and perform actions, while application code remains responsible for execution, authorization, validation, and error handling.

Tool calling separates language-model reasoning from external execution. An application supplies descriptions of available tools, including their names, purposes, and input schemas. When a supported model determines that a tool is appropriate, it produces a structured request identifying the tool and its arguments. The application or agent runtime validates that request, executes the operation, and returns the result to the model. The model can then answer the user, request another tool, or stop.

The model ordinarily does not execute the function itself. Generating a request to issue a refund is not the same as issuing the refund. Application code controls whether the operation is permitted, which credentials it uses, and whether user approval is required. Tool calls also do not inherently require an autonomous agent: a simple application can support a single lookup, while an agent can repeatedly select tools as part of a larger task.

In a cloud application, tools commonly wrap serverless functions, internal APIs, database access, search systems, or workflow executions. For example, a support assistant might call an order-status tool with an order identifier. The tool checks the authenticated customer's access, reads the order system, and returns a delivery estimate. A separate refund tool should enforce refund limits and require confirmation where appropriate. Avoid giving a model unrestricted database access when a narrowly scoped business operation will suffice.

Model Context Protocol, or MCP, standardizes how AI applications connect to servers that expose capabilities such as tools, resources, and prompts. An MCP client can discover tools and invoke them through the protocol, reducing the need for custom integration interfaces. MCP is not the model's reasoning process, and it does not replace authentication, authorization, input validation, or approval controls. Tool calling can also work without MCP through model-specific interfaces and application code.

In multi-agent systems, a supervisor may expose specialist agents through tool-like interfaces, delegate work to them, and combine their results. Other designs use peer communication or explicit handoffs. These communication patterns are related to tool usage but are not identical to it. Workflow orchestration defines sequencing, branching, approvals, and retries; tool calling supplies individual capabilities within that workflow. Deterministic orchestration is often preferable when business rules require a fixed execution path.

Memory management determines what information survives between calls and sessions. Recent tool results may remain in conversation context, while durable state belongs in an appropriate external store. Large responses consume context space and increase cost, so tools should return concise, relevant data. Store sensitive results only when necessary, and do not treat remembered information as proof that authorization is still valid.

Tool calling improves access to fresh data and reliable computation, but adds network latency, execution cost, and failure modes. Validate arguments against both schemas and business rules, apply least-privilege permissions, set timeouts and iteration limits, and log execution outcomes. Use idempotency controls for retryable operations that change state. Treat tool responses as untrusted data because retrieved content can contain prompt-injection instructions. A successful call does not guarantee a correct final answer: engineers must evaluate tool selection, argument accuracy, execution results, and the model's interpretation separately.

Key aspects of Tool Calling

Effective tool calling combines clear interfaces, application-controlled execution, reliable result handling, and bounded integration with agent workflows.

Explicit tool contracts

Describe each tool's purpose and accepted arguments with a clear schema. Narrow, unambiguous contracts help the model select the right operation and simplify application-side validation.

Separation of selection and execution

The model proposes a tool call; the application or runtime executes it. Keep credentials, authorization decisions, and business-rule enforcement outside the model.

Result-driven interaction

Return tool outcomes to the model so it can answer using external evidence or choose a subsequent operation. Handle failures explicitly rather than allowing the model to assume that an action succeeded.

Controlled interoperability

Tools can be exposed through custom APIs or standardized interfaces such as MCP. Standardized discovery and invocation reduce integration work but do not eliminate security controls.

Agent and workflow integration

Agents can select tools dynamically, while workflow engines can impose fixed ordering, approvals, and retry policies. Specialist agents can also be presented as callable capabilities when delegation fits the application.

Bounded and observable execution

Set timeouts, call limits, and cost budgets, and record tool requests and outcomes with appropriate data protection. Use idempotency and approval gates to reduce the risk of duplicate or unauthorized changes.

Cloud services for Tool Calling

Amazon Bedrock provides model interfaces that can request tools, while application code or an agent runtime controls execution. AWS Lambda can implement narrowly scoped operations, and Amazon API Gateway can expose backend capabilities through protected API endpoints. AWS Step Functions can coordinate operations that require multiple steps, recovery logic, or approval waits. Together, these services separate probabilistic model decisions from controlled business execution. Engineers still need to validate arguments, enforce caller-specific permissions, protect sensitive results, and return accurate execution outcomes to the model.

Amazon Bedrock

Amazon Bedrock supports tool use with compatible models, including through the Converse API, where application code handles requested tool execution and returns results. Agents for Amazon Bedrock can orchestrate action-group operations through AWS Lambda or return control to the application.

Open Amazon Bedrock →
AWS Lambda image AWS Lambda

AWS Lambda can implement tool operations such as looking up an order or submitting an approved request. Functions should validate inputs, enforce business rules, and use narrowly scoped execution-role permissions.

Open AWS Lambda →
Amazon API Gateway image Amazon API Gateway

Amazon API Gateway can expose backend operations as authenticated APIs that an application's tool-execution layer invokes. Authorization, throttling, and request validation help protect these endpoints, but application-specific authorization still requires appropriate implementation.

Open Amazon API Gateway →
AWS Step Functions image AWS Step Functions

AWS Step Functions coordinates multi-step tool operations using explicit workflow states, retries, timeouts, and error handling. An application can expose a workflow as a tool while keeping consequential execution paths under deterministic control.

Open AWS Step Functions →