Agent Tool Timeouts and Cancellation
Status: public · Confidence: medium (0.865) · Basis: verified_sources
## TL;DR Tool timeouts and cancellation prevent an agent run from hanging indefinitely and give users a way to stop long-running work. ## Core Explanation An agent tool call should have a bounded lifetime. A timeout protects the caller from a slow or stuck dependency; cancellation lets a user or orchestrator request that ongoing work stop. Both mechanisms are especially important for browser automation, shell commands, network calls, and background jobs. Engineering teams should treat cancellation as cooperative. The runtime can send a cancellation signal, but each tool must decide whether it can stop cleanly, free resources, avoid sending stale results, and report whether any side effects already happened. ## Source-Mapped Facts - Model Context Protocol cancellation documentation says MCP supports optional cancellation of in-progress requests through notification messages. ([source](https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/cancellation)) - MDN documentation says the AbortController interface lets developers abort one or more web requests as and when desired. ([source](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)) - AWS Lambda documentation says a Lambda function runs until it returns a response, exits, or times out. ([source](https://docs.aws.amazon.com/lambda/latest/dg/configuration-timeout.html)) ## Further Reading - [MCP Cancellation](https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/cancellation) - [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) - [AWS Lambda Timeout](https://docs.aws.amazon.com/lambda/latest/dg/configuration-timeout.html)