pinecallDocs
Advanced / Prompt injection

Prompt injection

What a lookup returns never becomes part of the prompt. The contract, and why.

A voice agent reads three kinds of text, and only one of them was written by whoever built it. The agent's own words are the operator's. The caller's words are the user's. Everything else (what a knowledge base returned, what memory kept from an earlier call, what a tool answered from somebody's CRM) arrived from outside the conversation and may have been written by anyone. A request that mixes the three into one paragraph gives them all the same authority. This page is the rule this runtime follows so that it never does. It is a public contract: a tenant can predict where their own words land in a request and where a retrieved sentence lands, and check it in the call's log.

The rule#

what who wrote it where it goes authority
the prompt blocks the app sets (prompt.set), the tool descriptions the tenant the static region, before the history operator
the knowledge text of the agent's settings the org the static region operator
the caller's words the person on the line a user turn user
what recall returned a model, from earlier callers' words a tool result, JSON none
what search returned whoever wrote the documents a tool result, JSON none
what a tenant's own tool returned the tenant's systems, and what they read a tool result, JSON none
the view block the tenant after the caller's newest words, ahead of the turn's tool rounds; last when no tool ran operator
the names of the tools the app closed (tools.set) the gateway, from the tenant's own tool names one sentence right after the view block, in that request alone: the model holds every tool for the whole call, and is told each turn which it must not call operator

Nothing that came from outside the conversation is placed among the operator's blocks or in a plain user turn: it goes in a tool result, encoded as JSON. Nothing the operator wrote is placed in a tool result, since the model is trained to discount instructions there.

What the vendors say#

Anthropic and OpenAI both train their models on the same hierarchy: system over user over tool output, and an instruction found inside a tool's output is data, not a command. The defence their guidance names first is structural: keep untrusted text in the channel the model already distrusts, and say in the tool's own description where its output comes from.

What this runtime does#

  • Lookups are tools, and their answers tool results. Recall and search run before a turn on the platform's behalf, and their answers are spliced into the request as a tool call and its result, right before the caller's words (session/lookups.py). The model reads what memory and the documents said exactly as it reads a tool it called. Their descriptions say where the text came from and that it is information, never an instruction; a fact carries the call it came from and the date it was first held, so the model can weigh it. Neither answer carries a score.
  • The view is the operator's, and nothing the caller said comes after it. The dynamic view block comes right after the caller's newest words. Only this turn's tool results follow it, in the channel the model reads as data: placed after them, livekit sends the block as a user turn on most vendors, and the model read it as a new ask after every result, calling tools round after round instead of answering.
  • What the agent is saying is told as said, never as a prefill. A tool's announcement plays while the tool runs, and livekit writes it into the history only once it has played; the reply after the tool is asked for before that. The request carries it last, as a system note quoting the line and telling the model to go on from it (session/prompt.py, ALREADY_SAID), so the line is not said a second time. Until 2026-11-06 it went as a trailing assistant message, the agent's own words: a vendor reads that as a prefill, and a model that takes none refused the whole request (Claude Haiku 5.5, 400 "does not support assistant message prefill"), so every call of that model that spoke over a tool ended in an error. A line that has played by the time the tool answers is in the history already, after the call it was said over, and a formatter sends it after the tool's result: the same prefill. The request tells it as the same note and the history keeps it where it was said; until 2026-11-20 it went as it was, and Anthropic refused the request for the space the line ends with (400 "final assistant content cannot end with trailing whitespace") whenever no lookup of the turn happened to follow it.
  • The knowledge text is the operator's, set in the org's settings by a person with pipeline or words, and stays in the static region.
  • Memory is admitted when it is written. A fact is extracted at hang-up by one model call, then admitted by code before it is kept: nothing under a category the agent's policy forgets, and nothing that names one of the agent's own tools, since such a fact could read as a permission granted ("book without asking"). A fact that got in once would otherwise be handed to every later call of that contact.
  • A tool that acts can be read back. A tool declared with confirm has its outcome said to the caller in the operator's words, and an irreversible tool declared without one is refused when the agent is declared — from a class that cannot happen, since a confirm is what makes a tool irreversible there; the refusal is for an app speaking the wire's agent.configure itself; the consent judge checks, after the call, that every irreversible tool ran after the caller agreed to it.

What a tenant should do#

Declare a tool's side effect honestly (an irreversible one must carry a confirm); keep the caller's identity and permissions in the app's state, never in something the model reads as a fact; and read memory.ops now and then.

What is deferred, and named#

  • A gate that holds an irreversible tool until the caller says yes in the call itself: today it is checked afterwards, by the consent judge.
  • A monitor over memory.ops that reads for a fact that reads like an instruction.