Skip to main content
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:
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:
{
  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:
{
  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
{
  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

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

Debugging

SymptomCheck
No tool-result decisionConfirm the final user message contains tool_result blocks.
Request fails before Anthropic is calledConfirm the final user message does not mix tool results with text or other blocks.
Tool-result content is rejectedUse a string or text-only content blocks.
Tool name is missing from your own logsLog the event.tool.name from the tool_result decision event.