# Agent interface control

An agent working with you can show you things in Phantom: open a note and
highlight a sentence, open a request in History and point at its
`Authorization` header, select the rows it is talking about, or bring up
Reports. It happens in your open window, without a reload, and every action
says so in a quiet toast with the agent's name.

Agents only **show**. Nothing here sends a request, saves, deletes or
changes data on the agent's behalf. The one thing Phantom writes is your
own unsaved work, which it saves before the window moves, exactly as the
autosave would.

## What an agent can do

| Tool | What it does |
|---|---|
| `ui_open(ref)` | Opens a request (`flow`), `note`, `finding`, `report`, `report_section`, `comparison`, `repeater_tab` or `asset` in its own module. |
| `ui_highlight(ref, text \| line_start[, line_end], occurrence?, part?)` | Opens a note, a report section or a request and highlights the nth occurrence of a text, or a range of lines, scrolled into view. For a request, `part` picks `request` (default) or `response`. |
| `ui_select(module, ids)` | Selects rows; today `history` (flow ids). The first row opens in the request panel. No bulk action runs. |
| `ui_navigate(target)` | Brings up a page: `proxy/history`, `proxy/intercept`, `proxy/repeater`, `proxy/intruder`, `proxy/comparer`, `proxy/decoder`, `proxy/timeline`, `notes`, `notes/graph`, `findings`, `reports`, `targets`, `assets`, `scans`, `payloads`, `agent`, `settings/overview`, `settings/agents`, `settings/providers`, `settings/activity`. |

Every tool also takes `conversation_id` (default: your most recent
conversation that shares context), `vault_id` and `window` (a window id from
`workspace_context_get`; default: the most recently active one). Settings
pages that create tokens or change permissions or redaction are not on the
list: an agent cannot steer you towards them.

### Highlights

- Matching is case-insensitive and runs on what you see, so a masked
  credential only matches its mask (`••••`). Highlighting a masked value
  never reveals it.
- In a note or a section the highlight is a temporary decoration in the
  editor (soft vermillion that settles after a brief flash). It is not part
  of the text, the undo history or any revision. Esc or a click removes it.
  In the reading view it is a highlight over the rendered page.
- In the message viewer it uses the find marks; the viewer switches to Raw
  if it was on a view without text. Esc or a click clears it.
- The result says `found: true` or `false` when the view could answer.

## Permissions

All four tools need **`bridge.execute`** and the **read grant** of what they
show (`notes.read` to open a note, `http_evidence.read` for requests and
History, the module's resource for a page, see [Agent
permissions](permissions.md)). Objects are resolved in the conversation's
vault; one from another vault answers `not_found`, like one that does not
exist. A conversation of another agent is `not_found` too.

The **Research assistant** and **Full access** presets include
`bridge.execute`; **Read only** does not, so a read-only agent can talk to you
and read the workspace context but cannot move your window.

Every call leaves one row in Settings → AI & Agents → Activity.

## Which window

An action goes to exactly one window: a live window showing the
conversation's vault, while that conversation shares the workspace context.
Phantom knows windows from the context they publish over the WebSocket
(`docs/design/workspace-context.md`); the action is sent as a `ui.action`
event aimed at that window only, and only the connection that carries the
window can answer it with `{"op": "ui.ack", "action_id", "status"}`.

The tool answers with one of:

| `status` | `reason` | Meaning |
|---|---|---|
| `delivered` | | The window showed it (`found` / `matched` when known). |
| `no_window` | `no_conversation`, `not_shared`, `no_window`, `timeout` | No conversation sharing context, no live window in its vault, or no answer within 5 s. |
| `window_declined` | `switched_off`, `unsaved_work`, `not_shown` | You turned Navigate off, unsaved work could not be saved, or the page could not show it. |

## Transparency and control

- **Toast.** Each action shows what happened: "Claude Code opened note
  “Checklist”", "… selected 2 requests in History".
- **Navigate.** A labelled chip per conversation beside Sharing, in the
  Agent page header and under the agent panel's header, on by default. Off, the conversation's agent gets
  `window_declined` and your window does not move. It is an interface
  preference of this browser.
- **The conversation stays in view.** When an agent takes the window to
  another page, the agent panel opens there (Ctrl+. or the rail button
  closes it again), so a conversation started on the Agent page follows
  you.
- **Unsaved work.** Before the window moves, the open note and the report
  section being written are saved. If a save fails the window stays where
  it is and the agent is told `unsaved_work`.
- **Context sharing.** Pausing context sharing for a conversation also stops
  its agent from driving the window (`not_shared`).
