Availability
Available from Tyk AI Studio 2.3.0.
Overview
Agents read web pages, files, and API responses. Any of these can contain hidden instructions for the model. This is indirect prompt injection. A request guardrail can examine three parts of agent traffic in addition to the messages:- Tool results: the output of a tool that the client sends back to the model.
- Tool calls: the arguments of a tool that the model asks to run.
- Tool definitions: the name, description, and schema of each tool that a request offers the model.
Tool Results
Tool output, such as a fetched web page, a file, or an MCP or API response, is the main path for indirect prompt injection. Request guardrails scan tool results by default.
The guardrail examines a tool result as a whole. When the tool result is JSON, it also examines the decoded text, with escapes such as
\n and \u read as the model reads them. It also decodes text documents that a request sends as base64.
In a chat room, the request guardrails of the chat also screen the tool output. They do this before the model, the user, or the stored conversation sees it. This includes REST tool output, the error text of a failed tool call, and a user’s answer to a client tool card.
Guardrails do not examine this content:
- Binary documents, such as PDF and Word files, and images
- Files that a request refers to by ID, and conversation state that the vendor stores
- The results of tools that the vendor runs inside one call. The guardrail examines them when the client sends them back on a later turn.
- In a chat room, the context that a data source adds to the prompt
Quarantine
Quarantine is for content that a client sends again on each turn, such as a tool result. If a guardrail blocks a request because of a tool result, the agent cannot continue. Its next request contains the same tool result. Quarantine replaces only the flagged tool result or message with the placeholder, and the request continues. AI Studio keeps the tool call ID, the tool name, and all other fields. If AI Studio cannot replace the content in place, it blocks the request. You can use these variables in the placeholder:{{detector}}: the detectors that flagged the text{{category}}: the categories of these detectors{{source}}: where the text came from, for exampletool result from read_file{{tool_name}}: the name of the tool
Tool Calls
A tool call is the point where an injection becomes an action, such as an email to an address that a web page chose. Tool-call scanning is off by default.
The behavior of Block depends on where the call is:
- In a response, the guardrail stops the response. The client never runs the call.
- In a request, the client already ran the call. The guardrail blocks the request, and each later request of that conversation.
- In a chat room, the guardrail examines the call before AI Studio runs it. A blocked call never runs, and the turn stops.
Tool Definitions
A tool description can contain instructions that the model follows. This is tool poisoning. Tool definitions often come from MCP servers or OpenAPI specifications that a third party wrote. Tool-definition scanning is off by default.
The Remove the tool action (
remove) deletes the flagged tool from the request, and the request continues. When no tool remains, or the request forces the removed tool, the guardrail blocks the request instead.
The guardrail also examines the tool lists that AI Studio builds itself:
- AI Studio can serve a tool over MCP. The request guardrails of that tool examine its operations when AI Studio builds the server. A removed operation is not in the tool list.
- In a chat room, the chat’s request guardrails examine its tools before each turn.