Untrusted tool output: when an agent believes what a web page or API says

Agents read tool results such as web pages, search hits, and API responses, and those results can contain instructions or false data. How to label tool output, constrain follow-up actions, and validate results.

Lesson 47 of 69 · 10 min read · practice only with authorization

Diagram

A tool result steering the next step

Follow the path. One example at a time.

Step 1 of 4

Tool call

The agent fetches a vendor status page.

Illustration: Tool call
fetch_url("https://status.vendor.example/incident")

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Hidden text

    What fails
    Pages can hide instructions in markup that users never see.
    Who is affected
    Users who trust the agent’s summary.
    What you would notice
    Answers that include links or steps the visible page does not show.
    What you change
    Extract visible text only and label the source in answers.
  2. Chained actions

    What fails
    A tool result leads directly to another tool call.
    Who is affected
    Systems the second tool can change.
    What you would notice
    Write actions taken right after reading external content.
    What you change
    Require confirmation when external content precedes a write.
  3. Wrong data

    What fails
    APIs and search results can simply be false.
    Who is affected
    Decisions made from the answer.
    What you would notice
    Answers that cite one source for a critical claim.
    What you change
    Validate structured results and show sources.

Testing with a staged page

Host a page in your lab with visible content and a hidden harmless canary instruction. Ask the agent to summarize it. If the canary shows up, hidden content reaches the model and you should strip or label it.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

A summary includes a link that is only in hidden markup. What is the fix?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

This page stands on its own. The lab and the glossary card are the next reading.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.

Glossary

  1. CardUntrusted tool outputThe model, or a page it fetched, returns text that a later system treats as a command.