Skip to content
47% off: the complete course for $79 (reg. $149)Order now →
Agent Builder

AI agent glossary

Tool result

The message your code sends back to the model after running a tool it requested, carrying the output or an error so the agent can continue.

When a model asks to call a tool, it is waiting for an answer. The tool result is that answer. In the Anthropic Messages API, it is a tool_result block inside a user message, linked to the original request by its tool_use_id and holding the tool's output as content. Other APIs use a similar structure with their own field names.

Errors belong in tool results too. Instead of crashing the loop, return a clear message describing what went wrong, marked as an error, such as the is_error flag in the Anthropic API. Models are often good at recovering when they can see that a file was missing or an argument was invalid.

Tool results are also a major consumer of context. A tool that returns an entire web page or ten thousand database rows fills the context window fast. Return only what the model needs, summarize or paginate large outputs, and include identifiers it can use in follow-up calls.

Example

The model requests read_file with path config.yaml. Your code finds no such file and replies with a tool result marked as an error: 'File not found: config.yaml. Files in this directory: config.yml, README.md.' The model retries with the correct name.

Learn more in the course

Related terms

Go from definitions to doing

Learn to use and build AI agents in 65 practical lessons.