Prompt injection map
Every place model-facing text is defined, assembled, or handed to a provider. Use it when changing agent behavior, and when reviewing anything that puts…

Every place model-facing text is defined, assembled, or handed to a provider. Use it when changing agent behavior, and when reviewing anything that puts untrusted content in front of the model.

"Injection" here has two senses, and both matter: what we inject (system prompt, ephemeral blocks) and what others could inject (fetched pages, comments, child results, model-authored tool descriptions). The second list is why every framed block that carries foreign text is escaped.

What we inject

Shared assistant instructions

File: agents/protocol/src/index.ts

    seedAssistantSystemPrompt({currentTime?, contextLines?}) (line 14) holds the shared Seed instructions: HM resource types, hm:// link formatting, the exact-block-ID rule, profile/:profile reads, :attributes, reading the activity feed with read activity:, and directory-then-children exploration.

    It takes no tool-specific options. There is no title-tool instruction: session titles are generated by a separate model call, not by a tool the agent holds.

Agent system prompt assembly

File: agents/src/api-service.ts — Service.#agentSystemPrompt() (line 4169). In order:

    the user-configured AgentDefinition.systemPrompt, stored as Seed blocks and converted to resolved markdown;

    seedAssistantSystemPrompt({currentTime});

    the memory prompt (line 4184) — unconditional, since memory is a verb address rather than a tool group. It describes ~/memory/, the check-memory-first habit, whole-file rewrites, {fromUrl} downloads, read ipfs://, write ipfs:// publishing, and that chat attachments are session-private and read with read attachment:<id>;

    the user-actions prompt (line 4190) — "Your user holds the same verbs you do… entries tagged <user_action>/<user_action_result> are actions the user ran themselves — read their results as shared ground truth";

    the <space> index (see below), present whenever the call passes a stateDir — which agent runs always do;

    <available_signing_identities> JSON plus signing/publishing instructions, only when the agent has signing keys — including the publish recipe and the parent-must-exist rule.

GetSession returns the fully assembled prompt as systemPromptMarkdown (line 5042) for UI inspection. That dialog is the ground truth for "what is this agent actually being told."

The Space index

File: agents/src/api-service.ts — buildSpaceIndex() (line 5900).

A <space> block in every system prompt: one line per enabled tool document (- name — summary, authored tools tagged (authored)), a one-line memory top-level summary, and active trigger names. Cached per (account, agent, callable set), invalidated on memory and tool writes, and collapsed to counts above 2048 bytes.

Note what this means for review: an agent's own authored tool text lands in its prompt. A lambda's summary reaches the system prompt through this index, and its description (bounded at 16 KiB) reaches the model in full whenever the tool is expanded or promoted. Both are model-authored text reappearing as instructions-shaped context. This is intended — self-configuration is the design — but it is the one prompt source the agent itself writes.

Ephemeral per-turn blocks

None of these are stored as events; they exist only in the replay handed to Pi.

    <plan_state> — planStateBlock() (line 414), appended as the last user message of every turn. The plan verb writes no transcript event, so this block is how a resumed model can see the checklist it published. Step ids and labels pass through escapeActionFraming(). A checklist that fully settled under an earlier run is not injected: the new turn retires it to the run that owned it (#retireSettledSessionPlan) and starts with no plan, so a new request never resurrects a finished list.

    <background_work_update> (line 4431) — pushed when a park-resume leaves the replay ending on an assistant message, which Pi cannot continue from. Tells the model its children finished and to act on their results.

    <window_context> (line 4914) — the desktop's current window, arriving as context content parts and formatted by formatWindowContextLines() (frontend/apps/desktop/src/components/assistant-window-context.ts:39). Kept out of the durable message content, so transcripts stay clean.

    <attachments> — formatAttachmentMetadata() (line 5970): name, MIME type, size, and id for each attached file, and never the bytes. Its guidance speaks verbs — read attachment:<id> to see an image or read a text file, write ~/memory/<path> with {fromAttachment} to keep one across sessions, write ipfs:// with {fromAttachment} to publish one — and closes with "Only read what you need." (It named the deleted view_attachment / attachment_to_memory / attachment_to_ipfs tools until 21a492a51; that class of drift is what this section exists to catch.)

Durable system messages

Written as real events with actor: 'system', so they are part of the record rather than a per-turn nudge:

    continuationPrompt() (line 447) — every open obligation at once, when a turn ends still owing something;

    unmetObligationsNotice() (line 457) — the closing notice when the continuation budget is spent.

Trigger-created sessions

File: agents/src/api-service.ts — triggerPromptMessage() (line 6138). The first user message of a triggered session carries the trigger prompt as resolved markdown, a <trigger_context> JSON block (trigger/firing/activity details), and a <trigger_instructions> block telling the agent to reply as a threaded comment with the write verb, naming where in the context to find the target document id and replyTo.

This is not a system prompt, but it is model-facing prompt text assembled from activity authored by other people — review it with system-prompt changes.

Delegated children

    A model child's brief becomes its first user message verbatim (renderSubSessionInput(), line 360); non-strings degrade to a bare fenced JSON block so nothing is reworded or hidden. The brief is the interface, and it is written by the parent model.

    spec.prompt replaces the child's system prompt entirely (line 2622) — an anonymous worker persona authored by the parent model.

    A typed child's return_result parameters are the spawner-declared schema, swapped in at session start (line 7938).

Tool contracts

File: agents/protocol/src/tool-registry.ts

Tool description and JSON-schema field descriptions are model-facing instructions, and for the five verbs they are substantial ones — the delegate description alone carries the parallelism doctrine and the whole ctx surface. The registry is shared with the desktop assistant runtime where runtimes overlap. Contracts also reach the model at runtime through read ~/tools/<name> and through touch-expand misses.

contractMarkdownForThisServer() (line 7641) narrows the execute contract to the runtimes this server can run, so the model is never instructed about a capability that would fail.

Session titling

#generateSessionTitle() (line 2966) runs one minimal, tool-less model call with its own fixed system prompt ("You are a session-titling assistant…") over a conversation digest. It uses the shared provider runtime so subscription-auth providers title correctly.

Pi boundary

createSeedPiResourceLoader(systemPrompt) (line 6852) injects the assembled prompt via getSystemPrompt() and disables every Pi discovery source: getAgentsFiles() returns none, getPrompts() returns none, getAppendSystemPrompt() returns an empty array, and skills/extensions/themes are empty. Combined with noTools: 'builtin', this keeps hosted Agents from implicitly loading local AGENTS.md, prompt templates, skills, extensions, or Pi's own host tools.

What others could inject

Ranked by exposure. Everything here is untrusted content that reaches the model.

    Fetched web pages (read https://…, web_search results). The largest surface; no escaping is applied to a page read by the agent itself, because it arrives as a tool result, which is the frame the model already treats as data.

    Hypermedia content and comments (read hm://…, activity feed, trigger context). Authored by other accounts. Trigger sessions are the sharpest case: the triggering comment is attacker-controlled text that arrives in the session's first message alongside instructions.

    User-action payloads and results — a user's read of a hostile page replays inside <user_action_result>. Escaped with escapeActionFraming() (line 9179) precisely because content that could close the frame would forge a trusted user action for everything after it.

    Plan step labels — model-authored, replayed inside <plan_state>. Same escape, same reason.

    Child results — re-enter the parent as tool-result data, schema-validated when typed. A prompt-injected child can corrupt only its own return value.

    Authored tool descriptions — see the Space index note above.

    Attachment file names — rendered into the <attachments> block unescaped.

Desktop surfaces

    Assistant panel (frontend/apps/desktop/src/components/assistant-panel.tsx) is a client of the agents service; it builds no system prompt of its own. It contributes window context as context content parts (line 562). The old app-chat.ts / chat-provider-options.ts local-assistant prompt path is gone.

    Default new-agent prompt: a single Embed block of the shared skill document (hm://z6Mko5npVz4Bx9Rf4vkRUf2swvb568SDbhLwStaha3HzgrLS/resources/skill, published at https://seed.hyper.media/resources/skill) — see defaultAgentSystemPrompt in frontend/packages/ui/src/agents/dialogs.tsx. User-editable, becomes AgentDefinition.systemPrompt; the service inlines the embedded document when it resolves the prompt, so whoever can edit that document shapes every new agent's prompt.

    Prompt tab (pages/agents/detail.tsx) edits those blocks with the Seed block editor; the server normalizes and resolves them to markdown before use.

    System prompt dialog (pages/agents/session.tsx) shows systemPromptMarkdown — the exact prompt that would be used to continue the session.

Change checklist

    Update shared instructions first when behavior should apply everywhere.

    Keep #agentSystemPrompt() assembly minimal and ordered; every block added is context spent on every turn.

    Prefer an ephemeral per-turn block over a durable event when the text is a reminder of current state rather than a record of something that happened.

    If a new block frames text authored by anyone but us, escape it, and add it to the untrusted list above.

    Update tool descriptions in agents/protocol/src/tool-registry.ts when behavior depends on tool use.

    Inspect a live session via GetSession.systemPromptMarkdown or the session UI dialog.

    Update this document if a prompt source is added, removed, or moved.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime