← Blog

Anthropic Tool Result Content Needs a Route Policy

Parminder Singh
Parminder Singh··7 min read
Summarize with AI

Anthropic accepts tool_result content as a string or supported content blocks, including text, image, document, and search results. That flexibility can carry third-party data and indirect prompt injection into the next Claude request. This guide defines type allowlists, source labels, classification, minimization, error handling, retention, and a fail-closed policy for routed tool results.

Platform & Architectureai-securityllm-securityagentic-aipolicy-enforcementdata-loss-preventionaudit
Anthropic Tool Result Content Needs a Route Policy

An Anthropic tool_result can carry a string or a list of supported content blocks. The current client-tool guidance includes text, images, documents, and search results. That flexibility lets a customer lookup, uploaded PDF, fetched webpage, or search response enter the next Claude request through one field.

I want every routed tool result to pass a content policy before it becomes model context. Schema validity gets the object through the API. Route policy decides if this caller may send this source and data class to this model.

TL;DR

  • Allow only the tool-result content types and sources approved for the application route. Enforce its size limits.
  • Keep third-party output inside tool_result blocks and label its source. Treat embedded instructions as untrusted data.
  • Classify and minimize content before the follow-up Claude request. Preserve a digest and policy outcome.
  • Use is_error: true for failed or invalid client calls. Keep diagnostic content bounded and exclude secrets.

Anthropic permits several result content shapes

Anthropic's tool-call handling guide says content on a client tool_result is optional. When present, it can be a string or a list containing text, image, document, or search_result blocks. The result also carries tool_use_id. An optional is_error marks a failed or invalid call.

Start policy evaluation after validating that outer shape. Select a rule by application route and tool name, then account for content type, authenticated principal, and destination model. Support lookup might permit text and a bounded image. Contract review can accept a document from its approved repository. For a payment tool, the policy may limit output to a compact status object serialized as text.

The Messages API reference is the schema authority for the request. Keep an adapter-version fixture beside the policy. Supported block variants and tool-specific restrictions can change.

Tool-specific variants need separate allowlists

Anthropic documents narrower result content for computer-use and browser-use member tools. Their client results also echo the same toolset_name carried by the corresponding tool_use. Member results permit text and image blocks, with browser-use results supporting documented browser-state behavior. A generic allowlist for every client tool would accept content that the selected member contract rejects.

Key the registry by provider API version, tool family, member name when applicable, and route. Each entry should define permitted block types and required correlation fields. It should also define source rules, byte or item limits set by the application, and approved downstream consumers. Unknown variants should fail closed. Preserve the raw type in protected diagnostics.

Keep provider schema and enterprise policy as separate decisions. A valid image can still contain a customer account page that this route may not send to Claude. A valid document can exceed the route's data-minimization rule. The per-route policy pattern gives those deployment differences a named owner and version.

Third-party content arrives as untrusted data

Anthropic's prompt-injection mitigation guide names webpages, inbound email, user uploads, third-party APIs, and tool results as indirect-injection sources. An attacker who influences that material can place instructions inside content Claude reads on the user's behalf.

Keep those bytes inside tool_result. Anthropic advises against moving them into the system prompt or an ordinary user text block. Label the nature and source of the content as well. An email body from an unknown sender deserves a different trust marker from a record read from an approved internal service.

A practical normalized envelope can identify the source system, resource type, retrieval time, tenant, trust state, and payload. JSON escaping gives third-party strings an explicit boundary. The model may still interpret the text. The application must therefore retain least privilege for every later tool decision.

A gray browser card showing "verified page" can mislead an operator when the text came from an unreviewed domain. Source labels belong in the evidence and the interface.

Classification runs before the next Messages request

A client tool executes outside the model request. Its result enters DeepInspect's boundary when the application places that content in the follow-up POST /v1/messages request routed to Anthropic. Inspect the final serialized request. Earlier application objects may omit wrappers, retrieved attachments, or text added during normalization.

Classify each result block and evaluate the route policy. The decision can permit, redact, replace, or block. A customer-support route may redact payment-card fields while preserving a ticket status. A source-code route may block a private key and permit surrounding compiler output. Image and document blocks need modality-aware handling rather than a text-only scan.

Record the tool-use ID and tool name from the matched assistant turn. Add the source label, content types, classifications, policy version, transformation outcome, and post-policy digest. Raw content belongs in a separately controlled evidence store only when the route has an approved purpose and retention period.

This is the request-side counterpart to prompt injection protection, which covers the wider containment stack.

Minimize results for the next model step

Anthropic's tool-definition guidance recommends high-signal tool responses with stable semantic identifiers and only the fields Claude needs for its next step. That is also a security property. Smaller results reduce unnecessary data transfer and the amount of untrusted text entering context. They also shrink the evidence volume that requires restricted storage.

Define an output projection for each tool. A customer lookup used to choose a shipping option may need country and service tier, plus a stable customer ID. It rarely needs the full support history, internal notes, OAuth metadata, or database columns copied by a generic serializer.

My blunt opinion is that returning an entire ORM object to Claude should fail review. It turns developer convenience into an undocumented disclosure policy.

Apply minimization before prompt-injection screening so the classifier sees the payload the model would receive. Then compute the post-policy digest over the exact serialized content sent in the routed request.

Error content needs its own policy

When a client tool fails or the call is invalid, Anthropic says to send a tool_result with is_error: true. Claude may respond by making another tool call. The application therefore also needs a bounded loop policy. Error content should help the model choose a safe next step without exposing stack traces, credentials, connection strings, SQL statements containing customer data, or internal network details.

Create a small error taxonomy owned by the application. Examples include invalid_input, denied, not_found, timeout, and temporary_failure. Map raw exceptions to those categories in server-side code. Return a short description. Add a safe retry hint only where the route permits another attempt.

Keep the raw exception in the application's protected operational record under its retention policy. Store the public error category and is_error flag with the tool-use ID and content digest in the model-exchange record. A model-visible error is an input to the next generation, while the application exception is diagnostic evidence for engineers.

Retention follows the content, not the wrapper

Payload risk survives the tool_result wrapper. A document block can carry a contract. An image can show a patient record. A search result can include personal data copied from a public page. Apply the classification's retention and deletion rules to the original result and any transformed copy sent to Anthropic. Apply its access rules as well.

Keep custody visible from the tool's source record through the application result object to the routed Messages request. Record where raw content persists at each point. If the gateway keeps only a digest and classification, state that explicitly. If a protected evidence store retains the body for an incident purpose, name its access group and expiry policy.

The AI audit log schema provides common identity, route, policy, timestamp, and outcome fields. Add source and transformation fields rather than placing raw tool output inside every audit event.

A route review should also verify the provider account and feature's contractual data treatment. Content policy controls what the enterprise sends. Anthropic owns service-side handling after receipt.

A destructive fixture should carry hostile and sensitive results

Run the deployed adapter and routed gateway against a controllable tool stub. Return a short permitted text result first. Then return text containing a synthetic prompt injection and a fake private key marker. Include a customer identifier. Confirm the route blocks or transforms each case according to its named policy and that the provider mock receives only accepted bytes.

Exercise every enabled content type. Use a one-page synthetic PDF and an image with a visible account number. Add a search result from an unapproved source label, an unknown block type, and a browser-use member result with the wrong toolset_name. The validator should reject unsupported shapes before content policy tries to normalize them.

For errors, return a raw exception containing a fake credential. Confirm that the model-visible result carries is_error: true and the approved category while the fake credential stays out of the Messages request. Print the accepted content types and post-policy digests in a narrow terminal report. Avoid printing the raw fixture payloads.

DeepInspect

DeepInspect can inspect tool-result content in authenticated user or agent HTTP requests deliberately routed through its proxy to Anthropic. It can enforce route-specific block-type and data policies, classify or redact accepted content, reject unknown or forbidden results, and write a per-decision record before the follow-up Messages request reaches Claude.

The application owns the tool and source authorization. It also owns raw exception handling, output projection, and later tool execution. DeepInspect sees only the serialized model request that crosses its routed HTTP boundary. Direct provider calls and local tool traffic remain outside its evidence.

Book a technical deep dive at deepinspect.ai.

Frequently asked questions

Which content types can an Anthropic client tool result contain?

Anthropic currently documents a string or a list of content blocks using text, image, document, or search-result types for ordinary client tools. Specific tool families can have narrower contracts. Validate against the selected tool and current API reference.

Should third-party tool output go in a system prompt?

Keep third-party output inside a tool_result block. Anthropic identifies tool output as an indirect prompt-injection source. It advises applications to distinguish that untrusted content from system instructions and ordinary user text.

What belongs in an error tool result?

Set is_error to true and preserve the exact tool_use_id. Return a bounded application error category or safe explanation. Keep raw stack traces, secrets, internal addresses, and sensitive query details in protected operational records.

Can a valid tool result bypass data policy?

Schema validity only establishes that the request matches Anthropic's accepted shape. The application route still needs source, type, classification, minimization, retention, and destination decisions before the result enters model context.