> ## Documentation Index
> Fetch the complete documentation index at: https://docs.averta.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool results

> Evaluate Anthropic `tool_result` content before it goes back to the model.

Tool results are untrusted input. They often contain retrieved documents, browser text, database rows, or API responses. Averta checks them before they re-enter the Anthropic tool loop.

## Continuation Shape

The wrapper evaluates tool results when the final user message is a pure Anthropic tool-result continuation:

```typescript theme={null}
messages.push({
  role: "assistant",
  content: response.content,
});

messages.push({
  role: "user",
  content: [
    {
      type: "tool_result",
      tool_use_id: "toolu_123",
      content: JSON.stringify({
        matches: ["Password reset links expire after 24 hours."],
      }),
    },
  ],
});

const nextMessage = await client.messages.create({
  model: process.env.ANTHROPIC_MODEL ?? "claude-sonnet-4-5",
  max_tokens: 512,
  messages,
  tools,
});
```

That continuation call runs the tool-result checkpoint before Anthropic sees the returned content.

## Pure Means Pure

The final user message must contain only `tool_result` blocks. This is valid:

```typescript theme={null}
{
  role: "user",
  content: [
    {
      type: "tool_result",
      tool_use_id: "toolu_123",
      content: "Search result text",
    },
  ],
}
```

This fails closed because it mixes tool results with extra user text:

```typescript theme={null}
{
  role: "user",
  content: [
    {
      type: "tool_result",
      tool_use_id: "toolu_123",
      content: "Search result text",
    },
    {
      type: "text",
      text: "Now answer the question.",
    },
  ],
}
```

If you need to add user text, send it as a separate later user turn after the tool continuation has completed.

## Supported Content

Tool-result content can be:

* a string
* an array of text-only content blocks

```typescript theme={null}
{
  type: "tool_result",
  tool_use_id: "toolu_123",
  content: [
    {
      type: "text",
      text: "Password reset links expire after 24 hours.",
    },
  ],
}
```

Non-text tool-result content blocks fail closed before provider execution.

## Block Behavior

If a tool-result decision is `block`:

* the wrapper throws `AvertaSdkError`
* the continuation request is not sent to Anthropic
* the model does not see the tool output

## Decision Callback

```typescript theme={null}
client = wrapAnthropic(client, {
  onDecision(event) {
    if (event.checkpointType === "tool_result") {
      console.log(event.tool.name, event.decision.decision);
    }
  },
});
```

## Debugging

| Symptom                                  | Check                                                                               |
| ---------------------------------------- | ----------------------------------------------------------------------------------- |
| No tool-result decision                  | Confirm the final user message contains `tool_result` blocks.                       |
| Request fails before Anthropic is called | Confirm the final user message does not mix tool results with text or other blocks. |
| Tool-result content is rejected          | Use a string or text-only content blocks.                                           |
| Tool name is missing from your own logs  | Log the `event.tool.name` from the `tool_result` decision event.                    |
