# 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 concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/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.

Practice exams covering Tool Calling: [AIF-C01 AWS Certified AI Practitioner](https://blowstack.com/practice-exams/aws-certified-ai-practitioner), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [MLA-C02 (beta) AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Tool Calling

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

1. **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.
2. **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.
3. **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.
4. **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.
5. **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.
6. **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](https://blowstack.com/tools/cloud-services-hub/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.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/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.
- **[Amazon API Gateway](https://blowstack.com/tools/cloud-services-hub/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.
- **[AWS Step Functions](https://blowstack.com/tools/cloud-services-hub/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.

## Tool Calling exam questions

Real practice exam questions on Tool Calling, with the correct answer and its explanation.

### Question 1 (AIF-C01)

**Question:**

A media company is building an AI agent that explains royalty payments. For each request, the agent must calculate an exact payment from user-provided values by running the company's existing, tested Python calculation code. Requests arrive intermittently, and the company does not want to manage servers. Which approach best meets these requirements?

**Correct answer:** Package the Python code in an AWS Lambda function and expose it as an agent tool. Have the application validate the tool arguments, invoke the function, and return the result to the model.

**Explanation:** Tool calling lets the model request a calculation while application code controls its execution. Lambda can run the tested Python code on demand without server management, and the model can use the returned result to explain the payment.

### Question 2 (MLA-C02 (beta))

**Question:**

A logistics company uses the Amazon Bedrock Converse API in an application that selects tools to book carrier pickups. Occasionally, the booking API commits a pickup but the tool executor times out before receiving the response. The model invocation succeeds, and retrying the booking sometimes creates a duplicate pickup. The carrier API supports idempotent submissions and booking-status queries using a client-supplied operation identifier.

An ML engineer must automate recovery from these timeouts, prevent duplicate pickups, and use Amazon CloudWatch to distinguish confirmed booking failures from operations whose outcomes are still unknown. Which solution meets these requirements?

**Correct answer:** Persist an identifier for each logical booking and reuse it for all submission attempts. After a timeout, query the booking status and use bounded retries with the same identifier when needed. Return the confirmed outcome or an explicit unresolved error to the model, and publish separate confirmed-failure and unresolved-outcome metrics.

**Explanation:** A stable operation identifier allows the carrier API to deduplicate repeated submissions for the same booking. Status queries reconcile operations that might have committed before a timeout. Bounded recovery prevents indefinite execution, and explicit outcome reporting prevents the model and monitoring system from confusing an unknown result with a confirmed failure or success.

### Question 3 (SAP-C03)

**Question:**

An engineering company has three AI assistants built with different agent frameworks. Each assistant uses an Amazon Bedrock model through the Converse API. The assistants must access live equipment diagnostics and submit maintenance requests through vendor-operated tool servers. The vendors provide authenticated remote endpoints that support standardized capability negotiation, tool discovery, and tool invocation over Streamable HTTP. They do not provide OpenAPI specifications.

The company wants to reuse these endpoints across all three frameworks without building a separate connector for every assistant–vendor combination. Newly published tools must become available without retraining models or redeploying assistant code. The applications must retain control over which model-requested operations are executed. All selected models support tool use.

Which design meets these requirements?

**Correct answer:** Implement a reusable MCP client integration in each assistant host. Initialize connections to the vendor servers, discover permitted tools, and map their descriptions and input schemas into Converse tool configurations. Validate model-generated tool requests, invoke the corresponding server tools, and return the results to the model. Refresh discovery to detect newly published tools.

**Explanation:** MCP provides the common client–server interface needed to reuse vendor capabilities across different agent frameworks. The assistant host bridges discovered MCP tools to the model's tool-use interface and dispatches approved requests back through MCP. Refreshing discovery makes new tools available without retraining or application redeployment. Execution control remains with the application rather than the model.

### Question 4 (AIP-C01)

**Question:**

A supply-chain company exposes two tools, get_available_stock and get_supplier_commitment, through one Amazon Bedrock AgentCore Gateway Lambda target. Both tools accept the same arguments: sku and warehouseId. A single existing AWS Lambda function implements both operations, but each operation queries a different authoritative system.

The Gateway target configuration includes a separate tool definition and input schema for each operation. The company must dispatch each invocation to the operation that the agent actually selected, validate its arguments, and reject unknown operations before querying either system. Dispatch must not depend on an additional model-generated operation argument.

Which implementation meets these requirements?

**Correct answer:** Read the selected tool name from the Gateway-provided Lambda client context. Resolve the target-qualified name through an explicit allowlist of supported tools, validate the event arguments for that tool, and invoke its corresponding backend handler. Reject unrecognized names.

**Explanation:** AgentCore Gateway supplies the selected tool name in Lambda client context, in bedrockAgentCoreToolName. Gateway tool names are target-qualified, so the dispatcher should explicitly map the expected qualified names to handlers. The Lambda event contains the tool arguments. This separates authoritative dispatch metadata from model-generated arguments and allows validation before accessing either backend.

## Practice Tool Calling in a full exam

Questions on Tool Calling in each practice exam, with every answer option and an explanation for each:

- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 14 questions
- [MLA-C02 (beta)](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 11 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 5 questions
- [AIF-C01](https://blowstack.com/practice-exams/aws-certified-ai-practitioner): 3 questions

## What is Tool Calling

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.

## Learn Tool Calling in lessons

11 short lessons on Tool Calling in 4 certification courses.

- AIF-C01: Tool Calling: from model request to external execution (Premium), https://app.blowstack.com/lessons/tool-calling-from-model-request-to-external-execution-aif-c01
- MLA-C02 (beta): AI Agents and Tool Calling: task execution versus tool requests (Premium), https://app.blowstack.com/lessons/ai-agents-and-tool-calling-task-execution-versus-tool-requests-mla-c02
- SAP-C03: Tool Calling: controlled execution loops (Premium), https://app.blowstack.com/lessons/tool-calling-controlled-execution-loops-sap-c03
- AIP-C01: Model Context Protocol and Tool Calling: capability access versus invocation decisions (Premium), https://app.blowstack.com/lessons/model-context-protocol-and-tool-calling-capability-access-versus-invocation-decisions-aip-c01
- AIF-C01: Model Context Protocol and Tool Calling: integration versus invocation (Premium), https://app.blowstack.com/lessons/model-context-protocol-and-tool-calling-integration-versus-invocation-aif-c01
- MLA-C02 (beta): Model Context Protocol vs. Tool Calling (Premium), https://app.blowstack.com/lessons/model-context-protocol-vs-tool-calling-mla-c02
