Skip to content

Agent runs recognized from traffic

Last updated: 2026-11-27T11:37:35-03:00 (UTC-3)

Observability · Traces and the span store · Trace explorer · Content capture

A coding agent makes dozens of model calls for one thing its user asked. In the request log they are dozens of unrelated rows. With agent_recognition the gateway groups them into runs: which coding agent made the calls, which calls belong to the same run, how many turns it took, which tools the agent ran in between, which subagents it started and where it compacted its context.

Nothing is installed or configured on the client. A coding agent sends its whole conversation with every model call, with headers of its own, and the gateway reads the run from that. It never changes a request and never refuses one because of what it read.

What a run keeps is labels and counts: the agent’s name, IDs, times, counters and a keyed hash of the task. Prompts, answers, tool arguments and tool results are not part of a run. The text the user typed to start the run is kept only when you turn on task capture, which is off by default.

features:
ui: true
usage_analytics: true
request_logs: true
session_tracking: true
agent_sessions: true
span_store: true # the steps of a run are stored spans
agent_recognition: true # default false; a tenant read
agent_transcript_ingest: false # default false; operator control; see "Transcript ingest"
# agent_recognition: # every field is optional; the defaults suit most installations
# task_capture: "off"

Both flags can also be switched in Settings → Features or with PUT /api/v1/admin/features/agent_recognition and PUT /api/v1/admin/features/agent_transcript_ingest, with no restart. The agent_recognition block is set in the gateway YAML and read on every request.

Flag Default Class Requires What it turns on
agent_recognition false tenant read agent_sessions (which needs session_tracking and request_logs) and span_store (which needs usage_analytics) Recognition on every inference request, the run registry, the Agent runs screen and the runs API
agent_transcript_ingest false operator control agent_recognition POST /v1/traces, the transcript ingest

With feature_plan_entitlements, a team reads runs and uploads transcripts only when its plan includes both agent_sessions and agent_recognition (entitlements).

Recognition applies to requests made with a key on the Chat Completions, Messages, Responses and generateContent routes. Calls the gateway makes itself (judges, helper calls, replays) and Playground calls are not runs. A run belongs to a team: requests of a key without a team are labelled with the agent’s name but are not listed as a run.

Before relying on derived run IDs, check digest_key in the effective settings: it must not say process.

Each client is recognized by a rule: a list of the headers and fixed texts that client sends. The gateway ships rules for the clients below, and you can add your own. The first rule that matches names the client; a request no rule matches is not recognized (unless agent_recognition.unknown_client says otherwise).

Every fact in a shipped rule comes from the client’s own documentation or source at a pinned version, and was then checked against the requests that version really sends. In the tables below:

  • observed means the signal was seen in requests of the named version, captured on 2026-11-25 by running the client against a local capture server (no provider call was made). The Grok CLI rule was observed on 2026-11-27 on real tasks through the gateway.
  • read means the client’s documentation or source states it, and it was not reproduced in a captured request.

The captured requests, cut down to what recognition reads, are the fixtures of the gateway’s own tests (47 requests in internal/gateway/testdata/agent_clients/).

Source: the LLM gateway protocol reference (sections “Request headers” and “Gateway hint headers”); requests of version 2.1.332.

Signal What the gateway reads from it Evidence
User-Agent: claude-cli/<version> (external, sdk-cli) The client observed
Header X-Claude-Code-Session-Id, sent by default; body metadata.user_id, a JSON string that holds session_id The run ID. It stays the same across tool steps, a continued session, a compaction and subagent calls observed
Headers x-claude-code-agent-id and x-claude-code-agent-type A subagent call and its type: the run <session>.<agent id> under the session’s run observed
cc_is_subagent=true in the first system block A subagent call, when no header says so observed
Header x-claude-code-parent-agent-id The agent that spawned a nested subagent read
Header x-claude-code-request-class: main, subagent, compaction The request class. Sent only when the client’s gateway hint headers are on observed
The same header with workflow (read as main) or auxiliary The request class read
Tool Agent (also Task) with input prompt The task given to a subagent observed
User text blocks that start with <system-reminder>, <local-command-caveat>, <command-name>, <local-command-stdout> or <task-notification> Context the client added. The typed text is the text block without such a wrapper observed
A last user text that starts with CRITICAL: Respond with TEXT ONLY. Do NOT call any tools. A compaction request observed
A conversation that starts with This session is being continued from a previous conversation that ran out of context. A compacted context window of the same run (the session ID does not change) observed

Source: github.com/openai/codex at tag rust-v0.172.0 (codex-rs/login/src/auth/default_client.rs, codex-api/src/requests/headers.rs, core/src/client.rs, protocol/src/protocol.rs, prompts/templates/compact/); requests of version 0.172.0.

Signal What the gateway reads from it Evidence
User-Agent: codex_exec/<version> (...) with header originator: codex_exec The client observed
User-Agent prefix codex_cli_rs/ (the default originator) The client read
Headers x-codex-turn-metadata, x-codex-window-id The client, when the User-Agent does not name it observed
Header session-id; body client_metadata.session_id and prompt_cache_key The run ID, unchanged after a compaction observed
Header thread-id The agent inside the run. A subagent has its own thread-id and its parent’s session-id: the run <session>.<thread> observed
Headers x-openai-subagent: collab_spawn and x-codex-parent-thread-id A subagent call and the agent that spawned it observed
x-openai-subagent with review (a subagent), compact (a compaction) or memory_consolidation (a helper call) The request class read
Tool spawn_agent with input message The task given to a subagent observed
User items that start with <environment_context> or # AGENTS.md instructions for Context the client added observed
A last user text that starts with You are performing a CONTEXT CHECKPOINT COMPACTION. A compaction request observed
A user item that starts with Another language model started to solve this problem and produced a summary of its thinking process. A compacted context window of the same run observed

Source: github.com/google-gemini/gemini-cli at tag v0.71.1 (packages/core/src/core/contentGenerator.ts, prompts/snippets.ts); requests of version 0.71.1 in API key mode.

Signal What the gateway reads from it Evidence
User-Agent: GeminiCLI-tui/<version>/<model> (...) (the rule matches the prefixes GeminiCLI- and GeminiCLI/) The client observed for GeminiCLI-tui/; the prefix GeminiCLI/ was not observed
No run ID in any header or body field The run ID is derived observed
A user part that starts with <session_context> Context the client added observed
A system prompt that contains You are a sub-agent within a larger development system. A subagent call, a derived run of its own observed
A task wrapped in <objective>…</objective> The subagent’s task, without the tags observed
Tool invoke_agent with input prompt The task given to a subagent observed
A system prompt that starts with You are a specialized Task Routing AI. A helper call observed
A system prompt that starts with You are a specialized system component responsible for distilling chat history A helper call (the client’s summarization) read

The client’s Code Assist mode is not recognized specially.

Source: the OpenCode source at tag v1.19.6 (packages/opencode/src/session/llm/request.ts, agent/prompt/compaction.txt); requests of version 1.19.6.

Signal What the gateway reads from it Evidence
User-Agent: opencode/<version> … The client observed
Header x-opencode-session-id, one per agent The run ID observed
Header x-opencode-session, sent to the vendor’s own providers The run ID read
Header x-opencode-parent-session-id A subagent: it has a session of its own, and this header names the run that spawned it observed
Tool task with input prompt The task given to a subagent observed
A system prompt that starts with You are a title generator. A helper call observed
A system prompt that starts with You are a context summarization agent. A helper call (the client’s summarization) read

Source: github.com/badlogic/pi-mono at tag v0.73.1 (packages/ai/src/providers/openai-responses.ts, packages/coding-agent/src/core/messages.ts); requests of version 0.73.1.

Signal What the gateway reads from it Evidence
A system prompt that contains operating inside pi, a coding agent harness (the client sends no identifying header: its User-Agent is its SDK’s default) The client observed
On the Responses API only: header session_id and body prompt_cache_key The run ID. On the other APIs the run ID is derived observed
A user text that starts with The conversation history before this point was compacted into the following summary: A compacted context window read

Source: the Grok CLI settings reference (custom models in ~/.grok/config.toml with a base_url, an env_key and an api_backend of messages, responses or chat_completions); requests of version 1.0.92 (@xai-official/grok) on the three backends, in headless mode.

Signal What the gateway reads from it Evidence
User-Agent: grok-shell/<version> (...) The client observed
Header x-grok-client-identifier (grok-shell) The client, when the User-Agent does not name it observed
Header x-grok-session-id The run ID, the same on the tool steps and on the turn summary of the run. The session title call sends it empty and is filed in no run observed
User texts that start with <user_info> or <system-reminder> Context the client added observed
A task wrapped in <user_query>…</user_query> The typed text, without the tags observed
A system prompt that starts with You are tasked with generating the session title. A helper call observed
A system prompt that starts with Write an ultra-short dashboard line that captures the AGENT'S REPLY A helper call (the turn summary) observed

Not read: x-grok-agent-id stayed the same across separate sessions of one installation, so it does not name an agent inside a run; subagents and compaction were not reproduced, and the rule states nothing about them. The helper calls go to the client’s own helper model name (grok-4.6 in this version) on the same endpoint as the custom model; without an alias of that name they are refused and the task still runs.

  • Cursor and Antigravity. Cursor’s editor calls the model from Cursor’s own servers, and reaches a custom endpoint only on a paid Cursor plan (not measured); its command-line agent talks only to Cursor’s API; Antigravity has no custom endpoint. None of their model calls reaches a gateway from the client, so there is nothing to observe and no rule is shipped. The evidence is in coding agents under a budget.
  • Aider. Its requests carry no identifying header and no run ID. You can add a rule of your own if your installation gives it something to match.
  • Not reproduced when the rules were verified: a client’s interactive-mode User-Agent, an automatic (not user-requested) compaction, and nested subagents. The rules cover them as far as the documentation or source states (the read rows above).
  • A new client version may change a header or a fixed text. A rule that no longer matches recognizes nothing; it never mislabels a request. See troubleshooting.

A run ID comes from one of three places, tried in this order. The run records which one as its basis.

Basis Where the ID comes from
declared The X-Gateway-Session-Id header (sessions). The gateway’s own header always wins: a client or a wrapper that sets it decides the run, and its X-Gateway-Parent-Session-Id the parent
client The client’s own run ID, read from the header or body field its rule names
derived A keyed digest the gateway computes, for a recognized client that sent no run ID

A fourth basis, transcript, marks a run that only a transcript upload named.

The run ID becomes the request’s session, and the client’s name its agent, unless the request already declared them with X-Gateway-Session-Id or X-Gateway-Agent-Id. So the request log, the stored spans, the agent session graph, the request event and the exported OTLP spans all carry the run with no setting of their own.

Some clients send no run ID. Every call of a run still repeats the start of its conversation unchanged, so the gateway derives the ID from that: derived- followed by 32 hexadecimal characters of an HMAC-SHA-256 over

  • the caller’s organization, team and key,
  • the client’s name,
  • the system prompt (its first 64 KiB), and
  • the user messages up to and including the first one the user typed.

The same first message, under the same key, with the same system prompt, gives the same digest. Most clients write the date and the working directory in the system prompt, which already tells apart runs that start with the same words in different places or on different days. For two such runs in one directory on one day, the gateway uses what the traffic shows: the request that begins a run looks like no later one. It holds one typed message, that message is its last item, and nothing from the model is in it yet.

  • The first run of a digest has the ID derived-<digest>.
  • When a request that begins a run arrives and the newest run of that digest has already received an answer, a new run starts: derived-<digest>-g2, then -g3, and so on (a generation).
  • Every other request (a tool step, a second prompt, a compaction) joins the newest run of its digest.
  • A beginning request that arrives while the newest run has no successful model call yet stays in that run: it is the first call sent again after a failure.

The gateway decides this with one indexed read of the run table, made only for derived runs, on the request path, bounded to 150 ms. A new generation also writes its row at that moment, so the run’s next call finds it on any replica. Clients that send a run ID, and requests with X-Gateway-Session-Id, cost nothing here. The read stays inside the key’s team and organization. If the database does not answer in time, the request is served as usual under the plain derived-<digest> ID, and agent_run_generation_failed is logged. A generation whose beginning request was never recorded (its usage row could not be written) stays listed with no model call, and the next beginning request of that digest uses it.

Two cases cannot be decided from the traffic, and the gateway does not guess:

  • Two identical runs of one key going on at the same time. While the first is still working, a second begins with the same bytes. The second starts its own generation, and from then on the later calls of both runs join that newest generation: the first run stops growing and the second counts the calls of both. If the first has no answer yet when the second begins, both are one run.
  • A client that sends its first message again, unchanged, after it was answered. That request is indistinguishable from the start of a new run, and starts a new generation.

Give such clients a run ID (a rule with run_headers, or X-Gateway-Session-Id) when this matters.

Other things to know before you rely on a derived ID:

  • A change at the start of the conversation is a new run. A client that rewrites its system prompt or its first message mid-run splits the run in two.
  • The digest needs a stable secret. The key comes from storage.provider_encryption_key_env, or from the console session signing key when there is no provider encryption key. Both are the same on every replica and after a restart. Without either, each process uses a random key (digest_key: process in the effective settings): every replica and every restart derives different IDs, and runs split. Configure one of the two secrets first.
  • Rotating that secret changes every derived ID once: runs in progress continue under a new ID.
  • Helper calls get no derived ID: a title or routing call does not begin like the run it serves.

agent_recognition.derive_run: false turns derivation off: only runs a client identifies, or a caller declares, are recognized.

Each recognized request has a class, read from the client’s own header when its rule names one, otherwise from the fixed texts of its rule:

Class Meaning
main A call of the run’s main agent
subagent A call of an agent the main agent started
compaction The client asks the model to summarize the conversation so far
auxiliary A helper call of the client that is not a step of the run: a session title, a routing decision

Compaction and helper calls are counted as model calls of the run. They start no turn, report no tool steps and never set the run’s task.

A turn is one thing the user typed and the calls it causes. The gateway tells typed text from the context a client adds around it by the rule’s context_prefixes.

  • Each model call records turn: how many typed messages the context window it sent holds. The number starts again after a compaction, because the window then holds a summary instead of the earlier messages.
  • The run’s turns counter adds one for each call whose last message is typed text (turn_start), which is the first call after the user typed.
  • A request answered with status 400 or above adds an error to the run, and no turn and no tool steps. The client sends the same messages again, and the request that succeeds brings them.

A coding agent runs its tools itself (a shell command, a file edit), so the gateway never sees a tool run. It sees the result come back: the client’s next request carries the tool results at the end of its conversation. Each result the run has not counted yet becomes a tool step of the run.

Which results are new is decided in two steps:

  1. The request offers the results of its last block. Reading the conversation back from its end, the block covers tool results and model messages that hold only tool calls. It ends at a model message with text, at a message the user typed, or after 256 results. This covers a client that writes each call next to its result (call, result, call, result, as some do on the Responses API) and a model that calls several tools in a row without writing anything.
  2. The run keeps the call IDs it already counted (the latest 256), and a result whose call ID is among them is not counted again. So a step is counted once, whichever request brings it: two tools of one model answer both count, and a step that a later request, a retry or a compaction sends again adds nothing.

A result with no usable call ID cannot be compared, so it counts only when it follows the model’s last message.

  • A step records the tool’s name and the call ID. Never the arguments, never the result.
  • The name of a tool is structure. The stored span of a step is named client tool; the tool’s name and call ID are only in its attributes tool and call_id, which are returned to readers with content_structure:read of the run’s team and withheld from everyone else (who reads what).
  • A step has no duration: its time is when the gateway learned of it.
  • A name is kept only when it is an identifier (letters, digits and a few separators, at most 64 bytes), a call ID only when it is at most 128 characters of letters, digits and _ - . :.
  • A result the client marks as an error (is_error on the Messages API) marks the step failed.
  • A tool whose result never comes back is not seen: the run ended, or the user interrupted it, before the next request.
  • At most agent_recognition.max_tool_steps new steps are recorded from one request; the rest are counted (tool_steps_dropped on the request span) and not offered again.
  • The tool steps of one request are stored as at most half of spans.max_spans_per_request spans. The run’s counter and the run block on the request span count every step.
  • Steps are recorded after the answer, when the run is updated, and only for a request that is recorded in the run: answered with a status below 400, with its usage row written. A request answered with status 400 or above counts none and gets no tool span; the client sends it again, and the request that succeeds brings the same steps. The tool_steps number on a request span is what that request added, so a request that only repeats known steps shows none.
  • Two requests of one run answered at the same instant may each record a span for the same tool step; the run’s tool_steps counter still counts it once.
  • If the gateway cannot read the run’s counted call IDs, the request adds no step (agent_run_counted_calls_failed is logged); a later request offers them again only when the model’s next message holds no text, so with a model message that carries text these steps are not recorded.

A subagent is its own run, listed as a branch of the run that started it. The link has a basis too:

Parent basis How the link is known
client The client names it: an agent ID header next to the session’s run ID (the subagent’s run is <run>.<agent id>), or a header that names the parent run. An agent ID that contains . is not used to build a run ID (it could name the branch of another run): that call stays in the session’s run
declared X-Gateway-Parent-Session-Id
inferred The parent’s next request shows the tool call that started a subagent (the rule’s spawn_tools), and the task in it hashes to the task a recent run began with
transcript A transcript upload placed the run under its parent

An inferred link is made only between runs of the same key, team and organization, for a run that has no parent yet, did not begin before the spawning run, is not that run’s own parent, and was last active within agent_recognition.link_window_minutes (default 30) before the parent’s request. It needs the subagent to have made a call already when the parent reports the spawn. A subagent started asynchronously, whose first call comes later, is not linked by inference: it is listed as a run of its own.

A run is never listed as its own branch, whatever a client sends as its parent.

When a conversation outgrows the model’s context window, the client replaces it with a summary and goes on.

  • The call that asks for the summary has class compaction.
  • The calls after it start with the client’s continuation text (the rule’s continuation_prefixes). They form a new context window of the same run; the run’s compactions counter adds one, and the thread shows a divider at that point.
  • One compaction is counted and drawn once. A compacted window is identified by the summary text (or texts) it began with, which the client repeats unchanged in every later call, so it stays the same window however far it grows. A window that was never compacted is identified by the user messages up to the first typed one; before anything is typed, by the first user message alone.
  • For a run with a client or declared ID, nothing else changes: the ID is the same before and after.
  • For a derived run, the start of the conversation changed, so the calls after a compaction derive a new ID and are a new run. The gateway names the run it continues (continues_run_id) only when exactly one other run of the same key and agent was active within link_window_minutes. With two candidates it names none rather than guess.
  • A client whose rule has no continuation text (see the tables above) shows no divider.

The task is the first thing the user typed in the run, without the client’s context blocks and without a wrapper the rule names (task_wrappers).

By default the gateway keeps only a keyed hash of it (its first 64 KiB). The hash is never returned by the API. It links a subagent to the tool call that started it, and it lets two runs with the same task be recognized as such inside a team. It is computed per organization and team, so the same task under another team gives another hash.

agent_recognition.task_capture keeps the text itself:

Value Keeps
off (default) The hash only
preview The first 200 characters
full The first 2,000 characters

The task text is captured content, and it follows the rules of content capture. It is stored only when all of these hold; otherwise the run keeps the hash alone:

  1. agent_recognition.task_capture is preview or full. The gateway refuses to load a configuration that sets either with agent_recognition on and content_capture off.
  2. features.content_capture is on.
  3. A content encryption key is configured (storage.content_encryption_key_env).
  4. The run’s team has an active content capture policy that keeps requests (capture: request or both, not disabled) and covers the call that begins the run: its key when the policy lists keys, its model when it lists models, its operation when it lists operations.
  5. The policy’s sample_rate draws the call. A team that keeps one request in a hundred keeps the task of about one run in a hundred.

How it is kept:

  • Sealed with the content key. The text has its own random data key (AES-256-GCM), wrapped by the content key, and both seals are bound to the run’s team, organization and run ID: a stored text cannot be moved to another run.
  • Retention is the policy’s. The text expires after the team policy’s retention_days (30 when the policy sets none). Past that it is unreadable for every reader and is removed within a minute; the run stays listed with the hash, and its task then reads hash_only.
  • Kept from the call that begins a run: the first call of its first turn. A later call stores the text only for a run that has recorded no task at all yet (recognition was turned on mid-run, or the first call could not be recorded). A run whose first call recorded its hash without text (it was sampled out, or task capture was off) keeps the hash alone. Turning task capture on does not add text to runs already listed.
  • Erased with the content it belongs to. An end-user deletion removes the task text of the runs whose first request is among the erased requests. Deleting a team’s captured content (POST /api/v1/admin/content-captures/delete with the team, also with a before time) removes the task text of that team’s runs, those that began before before when it is sent. A deletion narrowed to one request leaves it: a run is not a request. In every case the keyed hash stays.
  • Shown only while content capture is on. With features.content_capture turned off, the text already kept is shown to nobody (withheld); it still expires and can still be erased.
  • Covered by content key rotation. gateway content-rewrap moves the task texts with the captured records, the rotation counts them, and a replica refuses to retire a content key an unexpired task text still names (rotating the content key).

Who reads it: a person with content_sent:read of the run’s team. Each read is recorded in the control audit as agent_run_task.read (target run:<run_id> team:<team> view:sent) before the text is decrypted; a read that cannot be audited shows nothing. The API answers a task object with a state instead of leaving a reader to guess:

task.state Meaning
shown The text follows in task.text
withheld The text is kept, and you lack content_sent:read of the team, or content_capture is turned off, or the read could not be audited
hash_only No text is kept for this run: task capture kept none, or the text was erased, or it expired and was removed
expired The text passed its retention and is not removed yet (it is within a minute)
unreadable The content key that sealed it is not configured
none The run shows no task (it began with a compaction summary, or only helper calls were seen)
Where What
Table gateway_agent_runs (PostgreSQL, migration 220) One row per run: team, organization, run ID, key, principal, agent and agent type, the basis of the ID and of the parent link, the parent run, the run it continues, the task hash, first and last time, counters (model calls, tool steps, turns, compactions, errors), the call IDs of the latest 256 tool steps it counted, whether it was seen in traffic or in a transcript, the first request and trace ID. Under task capture also the sealed task text, its key reference and its expiry
The request span of each model call (span store, either engine) An attribute block run: client, client_basis (user_agent, header, system_prompt or user_agent_product), class, basis, turn, turn_start, compacted, window (a keyed digest that names the context window), agent_type, parent_basis, tool_steps, tool_steps_dropped
One span per new tool step Kind tool, sub-kind client_tool, name client tool, attributes tool and call_id (withheld without content_structure:read), reported_by: client, reported_error and agent; zero duration
The request log and the agent session graph The run ID as the session, the client as the agent, the parent run as the parent session
The control audit One agent_run_task.read row per task text read

The steps of a run are spans: they are sampled, bounded and retained like every other span (spans.sample_rate, spans.retention_days). The money of a run stays in the usage ledger; a run row holds no cost.

Exported OTLP spans (otlp_traces) carry the same run, in the OpenTelemetry GenAI conventions where one exists. The exported tool span keeps the convention’s name, execute_tool <tool>, and the tool’s name as gen_ai.tool.name: what your collector receives is yours to restrict.

Span Attributes
The request (server) span gen_ai.agent.name (the client), gen_ai.conversation.id (the run ID), gateway.agent_run.class, gateway.agent_run.basis, gateway.agent_run.turn, gateway.agent_run.compacted, gateway.agent_run.tool_steps
One execute_tool <tool> span per reported tool step, a child of the request span, with the same span ID as the stored one gen_ai.operation.name: execute_tool, gen_ai.tool.name, gen_ai.tool.type: function, gen_ai.tool.call.id, gen_ai.conversation.id, gateway.tool.reported_by: client, and gateway.tool.reported_error: true when the client reported a failure
  • A run is listed for agent_recognition.retention_days (default 30) after its last request, then deleted.
  • Its spans follow spans.retention_days; a run older than its spans is still listed, and its thread says that no span is stored.
  • Task text follows the capture policy’s retention_days.
  • The cleanup runs every minute on every replica, whatever the flag says: turning recognition off never keeps what it stored.

Observability → Agent runs lists the runs of a time range, most recent first: the agent, the task (as far as you may read it), the key, principal and team that own it, its counters and its first and last time. Filters narrow the list by agent, team, key and the start of a run ID. The list holds the runs a user started; a subagent run appears inside the thread of the run that started it.

A run opens as a thread: its model calls, tool steps and compaction dividers in time order, with the steps of its subagent branches, each marked with how the gateway knows it (observed, reported or uploaded). Each model call carries its request and trace ID; its trace is where captured content is shown, to readers the capture policy and their role allow. The same screen has a panel with the effective settings and the rules in the order they are tried, each with its source.

The screen is shown to roles with logs:read while agent_recognition, agent_sessions, session_tracking, request_logs and usage_analytics are on. The thread also needs span_store.

Every route needs a console session (or an admin Bearer token) and the permission named; the full contract is in the API reference. Answers carry Cache-Control: private, no-store.

Route Permission What it returns
GET /api/v1/admin/agent-runs logs:read One page of the runs active in a range, most recent first, with the agent names seen in it
GET /api/v1/admin/agent-runs/{id} logs:read One run as a thread: the run, its parent, its branches, the runs that continue it, and their steps
GET /api/v1/admin/agent-runs/settings config:read The effective agent_recognition block and the rules

GET /api/v1/admin/agent-runs takes these query parameters:

Parameter Default Meaning
from, to the last 24 hours The range, RFC 3339, at most 92 days. A run is listed when it was active inside it
team every team you may read One team. A team outside your membership answers 403 team_forbidden
agent all The exact agent name, one of the agents the answer lists
key all The exact key ID
principal all The exact principal (user or service account) of the key
run all The start of a run ID
scope roots roots leaves out subagent runs; all lists every run
limit 50 1 to 200 runs per page
cursor none The next_cursor of the page before
{
"runs": [
{
"team_id": "platform",
"organization_id": "acme",
"run_id": "0f025c3f-1934-47ed-9a4e-5e16e68e1d95",
"key_id": "key_7f3a",
"principal": "ana",
"agent": "claude-code",
"run_basis": "client",
"first_at": "2026-11-25T14:02:11Z",
"last_at": "2026-11-25T14:09:47Z",
"model_calls": 14,
"tool_steps": 11,
"turns": 2,
"compactions": 0,
"errors": 0,
"from_traffic": true,
"from_transcript": false,
"first_request_id": "req-01",
"first_trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"children": 1,
"task": {"state": "hash_only"}
}
],
"next_cursor": "",
"agents": ["claude-code", "codex"],
"from": "2026-11-24T14:10:00Z",
"to": "2026-11-25T14:11:00Z",
"task_capture": "off",
"tool_names_shown": true
}

GET /api/v1/admin/agent-runs/{id} takes team when several of your teams use the same run ID (without it, the most recent is read). Its answer has run, parent, branches (at most 100 runs, four levels deep), continuations, and steps. Each step has a kind (model_call, tool, turn, transcript_call, compaction), a source (traffic or transcript) and a basis:

Step basis Meaning
observed A request the gateway served
reported A tool step the client’s next request reported; the gateway did not see it run
uploaded From a transcript; not checked against the traffic

The answer also has gaps: plain statements of what the thread does not show (content is never part of a run; tool steps are reported, not observed; only the latest 1,000 spans of a run and the steps of its first 19 branches are read; a derived run is told from another that begins identically only by its beginning request; tool names withheld). A missing run, a run of another team or organization and a team outside your membership all answer the same 404 run_not_found.

No new permission: a run is read with the permissions that already govern logs and content.

To read Permission Built-in roles that hold it
The run list and a run’s thread (agent, IDs, owners, counters, times, classes, turns) logs:read admin, viewer, team_admin (an organization admin included), team_viewer, user
Tool names and call IDs, in a thread, a trace and a span content_structure:read of the run’s team the same roles, and operator (which holds no logs:read, so it does not reach the thread)
The task text content_sent:read of the run’s team admin, the organization admin, team_admin
Cost on a model call analytics:read, with usage_valuation on as for the request log
The effective settings and the rules config:read every built-in role

Team roles read the runs of their own teams, an organization admin those of its organization, admin and viewer every team’s. A custom role ceiling can withhold any of these permissions and never adds one. Without content_structure:read a thread still lists its tool steps, without their names. The same rule holds outside the thread: the trace view and the read of one span return a tool step’s span without its tool and call_id attributes, and span lists (the trace explorer’s included) never carry attributes. This covers the tool spans a client reported and those a transcript uploaded.

  • Identity comes from the key. The team, organization, key and principal of a run are those of the key that made the request (or uploaded the transcript). Nothing a client sends changes them: a run ID or an agent name is a label of the caller’s own traffic.
  • Inside a team, the key that began a run owns its place. Only that key sets the run’s parent or moves its start time. Another key of the same team that sends the same run ID adds its steps and counters to the run, and can neither move it under another run nor make it look older.
  • A run ID is unique inside a team and organization, not across them. Two teams whose clients happen to send the same run ID have two runs, each read only by its own team.
  • Derived IDs and task hashes differ per organization and team. The same bytes sent under another organization or another team give another derived run ID and another task hash, so nothing can be correlated across them.
  • The organization rule. Every read returns only the rows recorded under the team’s current organization, filtered in SQL before the page bound. A run of another organization answers like a run that does not exist.
  • A team that moves to another organization keeps its ID. The runs it recorded before stay with the organization that recorded them: neither the team’s own roles nor the administrators of its new organization read them. The former organization’s administrators do, as they read everything else the team recorded there: the runs are in their list, team=<team> narrows to the team that left, and a run opens with its steps, branches and parent (see when a team moves). A run that goes on after the move becomes a second row under the new organization, which the former organization never reads. A gateway-wide administrator stands above organizations and reads both.

All fields are optional. The block is read on every request, so a change applies to the next request with no restart. The gateway validates the whole block when it loads the configuration, with the flag on or off, so turning the flag on never applies a rule that cannot work.

Setting Default Accepted Effect
agent_recognition.builtin_clients true boolean false leaves only your own rules under clients
agent_recognition.unknown_client none none, user_agent_product What a request no rule matches is called. none: it is not recognized. user_agent_product: it is named by the product token of its User-Agent (lowercased, at most 64 characters), as a name only: no run is derived, no class, turn or tool step is read, and it joins a run only when the request declares X-Gateway-Session-Id
agent_recognition.derive_run true boolean false recognizes only runs the client identifies or the caller declares
agent_recognition.task_capture off off, preview, full Whether the typed task text is kept: task capture. Quote "off" in YAML
agent_recognition.link_window_minutes 30 1 to 1440 How far back a subagent’s parent, or the run a compacted derived run continues, is looked for when the client names none
agent_recognition.max_tool_steps 32 1 to 256 New tool steps recorded from one request; the rest are counted
agent_recognition.retention_days 30 1 to 3650 Days a run stays listed after its last request
agent_recognition.transcript_ingest.max_request_bytes 4194304 (4 MiB) 1024 to 33554432 (32 MiB) Largest POST /v1/traces body, also after decompression
agent_recognition.transcript_ingest.max_spans 1000 1 to 10000 Most spans in one upload
agent_recognition.clients empty at most 32 rules Your own client rules, tried before the shipped ones: add your own client rule

GET /api/v1/admin/agent-runs/settings returns the block as the gateway applies it, defaults filled in, and the rules in the order they are tried. It answers whatever the flags say, so you can see what turning them on would apply.

{
"enabled": true,
"transcript_ingest": false,
"builtin_clients": true,
"unknown_client": "none",
"derive_run": true,
"task_capture": "off",
"task_capture_chars": 0,
"task_capture_state": "off",
"link_window_minutes": 30,
"max_tool_steps": 32,
"retention_days": 30,
"transcript_ingest_limits": {"max_request_bytes": 4194304, "max_spans": 1000},
"clients": [{"name": "claude-code", "origin": "builtin", "user_agent_prefixes": ["claude-cli/"], "source": "..."}],
"digest_key": "provider_encryption_key",
"sources": {"task_capture": "default", "retention_days": "default"},
"restart_required": false
}
  • enabled is true when agent_recognition, agent_sessions and session_tracking are all on; transcript_ingest when also agent_transcript_ingest and span_store are.
  • task_capture_state says whether text can be kept: off, ready, content_capture_off or content_key_missing. ready still needs the team’s capture policy.
  • digest_key is provider_encryption_key, session_signing_key or process. With process, derived run IDs and task hashes change at every restart and differ between replicas.
  • sources says, for each field, whether its value is from the yaml or the default. Each rule’s origin is yaml or builtin.

The Agent runs screen shows the same in its settings panel.

Use a rule for an in-house agent, a client the gateway does not ship a rule for, or to replace a shipped rule (your rules are tried first, and the first match wins). Read the facts from the client’s documentation or from one of its real requests; do not guess a header.

agent_recognition:
clients:
- name: acme-agent
user_agent_prefixes: ["acme-agent/"]
run_headers: [x-acme-session-id]
run_body_fields: ["metadata.session_id"]
parent_run_headers: [x-acme-parent-session-id]
class_header: x-acme-request-kind
class_values: {worker: subagent, summarize: compaction, title: auxiliary}
context_prefixes: ["<environment>"]
spawn_tools: [spawn_agent]
spawn_prompt_fields: [prompt]
compaction_request_prefixes: ["Summarize the conversation so far."]
continuation_prefixes: ["Summary of the earlier conversation:"]
source: "Acme Agent 2.3 request reference, section Headers"

A request with User-Agent: acme-agent/2.3.0 is then recorded as agent acme-agent, in the run its x-acme-session-id names.

A rule matches when any of its three identity fields matches; every other field applies only to a request the rule matched.

Field Meaning
agent_recognition.clients[].name Required. The agent name recorded: 1 to 64 lowercase letters, digits, dots, underscores or dashes; no two of your rules may share one
agent_recognition.clients[].user_agent_prefixes Identity: the request’s User-Agent starts with one of these
agent_recognition.clients[].identity_headers Identity: the request carries one of these headers, with any value
agent_recognition.clients[].system_prompt_contains Identity: the system prompt (its first 64 KiB) contains one of these. Use it only for a client that sends nothing else, with a phrase no other prompt would hold
agent_recognition.clients[].run_headers Headers that carry the client’s own run ID; the first one present wins. A value is used when it is 1 to 128 printable characters and the header is sent once
agent_recognition.clients[].run_body_fields Body fields tried after the headers, as dotted paths (metadata.session_id). > reads a string field as a JSON document and goes on inside it: metadata.user_id>session_id
agent_recognition.clients[].agent_headers Headers that carry the ID of the agent inside the run. A value equal to the run ID is the main agent; any other makes the request a subagent run <run>.<agent id>, unless it contains ., in which case it is not used
agent_recognition.clients[].parent_agent_headers Headers that name the agent that spawned that subagent (for nested subagents)
agent_recognition.clients[].agent_type_headers Headers that carry a subagent’s declared type (the first 64 characters are kept)
agent_recognition.clients[].parent_run_headers Headers that name the run that spawned this one, for a client that gives every agent a run ID of its own
agent_recognition.clients[].class_header A header whose value classes the request
agent_recognition.clients[].class_values The values of that header, each mapped to main, subagent, compaction or auxiliary; at most 16. A value not listed leaves the class to the fixed texts
agent_recognition.clients[].subagent_system_contains System prompt text that marks a subagent’s request, when no header does
agent_recognition.clients[].auxiliary_system_prefixes System prompt prefixes of a helper call that is not a step of the run
agent_recognition.clients[].context_prefixes A user text block that starts with one of these is context the client added, not what the user typed
agent_recognition.clients[].task_wrappers Tag names the client wraps a task in (objective for <objective>…</objective>); the tags are dropped from the task
agent_recognition.clients[].spawn_tools The tools the client starts a subagent with
agent_recognition.clients[].spawn_prompt_fields The input fields of a spawn tool that carry the subagent’s task; the first one present is used
agent_recognition.clients[].compaction_request_prefixes The last user text of a request that asks the model for a summary starts with one of these
agent_recognition.clients[].continuation_prefixes After compacting, the conversation restarts with a user text that starts with one of these
agent_recognition.clients[].source Optional, at most 512 characters: where the rule’s facts come from. Shown with the rule in the settings

Rules of the rules:

  • Every list holds at most 16 entries of 1 to 256 characters. Text is matched exactly, as a prefix or a substring, case-sensitive; there are no patterns. Header names are case-insensitive.
  • A rule needs at least one of user_agent_prefixes, identity_headers and system_prompt_contains.
  • Credential headers are refused. A run or agent ID is stored and shown, so a header whose value is a secret can never be read as one: Authorization, Proxy-Authorization, Cookie, Set-Cookie, X-Api-Key, Api-Key and X-Goog-Api-Key are refused in every header field, and the gateway does not load a configuration that names one.
  • A rule is a label, not a control: anyone who holds a key can send the headers a rule reads. Recognition never grants access, and what it records stays inside the key’s own team and organization.

Traffic shows what passes through the gateway. A coding agent also keeps its own transcript of the session, which knows more: turns in which no model call reached this gateway, tools whose result never came back, which subagent a step belongs to, and the moment of a compaction. With agent_transcript_ingest, a client plugin uploads that transcript after each turn as OpenTelemetry spans, and the gateway files them under the same run.

POST /v1/traces accepts an OTLP/HTTP trace export as JSON. With otlp_ingest on, the same route takes application spans, and a transcript upload must carry the header X-Gateway-Ingest: transcript (add it to the plugin’s exporter headers).

  • Authentication: a gateway key of a team with the scope traces:write. Add the scope when you create the key (scopes on POST /api/v1/admin/keys, or the key form in the console).
  • Format: Content-Type: application/json, optionally Content-Encoding: gzip. OTLP protobuf answers 415 unsupported_media_type.
  • Both span engines: the spans are written to the engine spans.engine selects, like the gateway’s own.
Terminal window
curl -sS https://gateway.example.com/v1/traces \
-H "Authorization: Bearer <key with traces:write>" \
-H "Content-Type: application/json" \
-d '{
"resourceSpans": [{
"resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "acme-agent"}}]},
"scopeSpans": [{
"spans": [
{
"traceId": "5b8efff798038103d269b633813fc60c",
"spanId": "eee19b7ec3c1b174",
"startTimeUnixNano": "1795615331000000000",
"endTimeUnixNano": "1795615339000000000",
"attributes": [
{"key": "gen_ai.operation.name", "value": {"stringValue": "invoke_agent"}},
{"key": "gen_ai.conversation.id", "value": {"stringValue": "session-42"}}
]
},
{
"traceId": "5b8efff798038103d269b633813fc60c",
"spanId": "eee19b7ec3c1b175",
"parentSpanId": "eee19b7ec3c1b174",
"startTimeUnixNano": "1795615332000000000",
"endTimeUnixNano": "1795615333000000000",
"attributes": [
{"key": "gen_ai.operation.name", "value": {"stringValue": "execute_tool"}},
{"key": "gen_ai.conversation.id", "value": {"stringValue": "session-42"}},
{"key": "gen_ai.tool.name", "value": {"stringValue": "bash"}},
{"key": "gen_ai.tool.call.id", "value": {"stringValue": "call_1"}}
]
}
]
}]
}]
}'

The answer is OTLP’s own: {} when every span was stored (or was stored already), otherwise a partialSuccess:

{"partialSuccess": {"rejectedSpans": "1", "errorMessage": "Spans without gen_ai.conversation.id, with an operation other than invoke_agent, chat, execute_tool or compaction, with unusable IDs or times, or past the per-trace bound were not stored"}}

The write is synchronous: a 200 means the spans are stored.

An upload counts as a request in the key’s request rate policies. With rate_limits on, each upload takes one slot in the requests-per-minute policies that an inference request of the same key counts in: the key’s, its team’s, its organization’s and, with end_user_rate_limits and an X-Gateway-End-User-Id header, the end user’s. They are the same counters, so uploads and model calls share one ceiling. Past it the upload answers 429 rate_limit_exceeded with a Retry-After header, before its body is read, and nothing is stored; send it again after that time. Concurrency caps (max_concurrent), model policies and token limits do not apply to uploads. A caller without a valid key or without the scope is refused first and takes no slot.

An upload is also bounded by its size and span limits (limits of one upload) and by the key’s scope, so give traces:write only to the keys that need it.

A span is kept when all of this holds; any other span is counted in rejectedSpans and the rest of the upload is still stored.

Requirement Detail
gen_ai.operation.name invoke_agent (a turn), chat (a model call), execute_tool (a tool), or the gateway’s own compaction (the client marks where it compacted)
gen_ai.conversation.id Required: the run, 1 to 128 printable characters. Use the session ID the client sends on its requests, so the transcript joins the run the traffic recognized
traceId, spanId W3C hexadecimal, 32 and 16 characters, not all zeros; parentSpanId, when sent, 16
startTimeUnixNano, endTimeUnixNano Both present, the end not before the start. The start must be within spans.retention_days in the past and at most 5 minutes ahead. A duration is capped at 24 hours

What else is read:

Attribute Used for
gen_ai.agent.id When it differs from the conversation ID, the span belongs to a subagent run <conversation>.<agent id> under the conversation’s run: the same ID the traffic gives a subagent whose client names its agents
gen_ai.agent.name (on the span, or on the resource; service.name otherwise) The agent’s name, written as lowercase letters, digits, dots, underscores and dashes. On a subagent’s span it is the subagent’s type
gen_ai.request.model, else gen_ai.response.model The model of a chat span. It must be an identifier (letters, digits and _ - . : / @, at most 256 bytes); any other value leaves the model empty
gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, gen_ai.usage.cache_read.input_tokens, gen_ai.usage.cache_creation.input_tokens The token counts of a chat span
gen_ai.tool.name, gen_ai.tool.call.id The tool of an execute_tool span, under the same rules as a tool step
status.code 2 marks the span failed

String attributes longer than 256 bytes are ignored. The stored spans have kind app and the sub-kinds transcript_turn, transcript_call, transcript_tool and transcript_compaction.

What is discarded, and why uploads are safe to repeat

Section titled “What is discarded, and why uploads are safe to repeat”

This endpoint is a write a client controls, so it trusts nothing in the upload:

  • Identity is the key’s. Team, organization, key and principal come from the authenticated key. An upload cannot place a span in another team.
  • All content is discarded unread: gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions, gen_ai.tool.call.arguments, gen_ai.tool.call.result, gen_ai.prompt and gen_ai.completion. A span that carried any is marked content: discarded. Every attribute not listed above is ignored.
  • Span names are not copied. The stored name is rebuilt from the operation (chat <model>, transcript tool, invoke_agent <agent>, compaction). The name of a tool is structure: it is kept in the span’s attributes tool and call_id, withheld from readers without content_structure:read, never in the span’s name.
  • Stored IDs are keyed digests. The stored trace and span IDs are digests of the uploaded ones within the team and organization. An upload can neither name nor overwrite a span the gateway stored, and the same IDs uploaded by another team are that team’s own, separate spans. A parent span is kept only when the same upload carries it.
  • A repeated upload writes each span once. A plugin usually sends the whole session again after every turn; only the spans not stored yet are written, and only they are counted.
  • A transcript does not double-count. For a run the gateway also saw in traffic, the run’s counters stay those of the traffic: the model calls a transcript names are the requests the gateway already served. A run only the transcript knows (basis transcript) takes its counters from the transcript.

Uploaded steps appear in the thread with basis uploaded. They are not checked against the traffic.

Limit Value Answer when exceeded
Body size, before and after decompression agent_recognition.transcript_ingest.max_request_bytes (default 4 MiB) 413 request_too_large
Spans agent_recognition.transcript_ingest.max_spans (default 1000) 413 too_many_spans
Traces 16 400 invalid_request
Spans of one trace spans.max_spans_per_trace the surplus is counted in rejectedSpans, and that upload adds nothing to the run’s counters (the gateway cannot tell which spans were left out)
Spans a trace already holds 2,000, the most one trace read returns 413 trace_too_large: the trace takes no more. Start a new session, or upload less

Other answers, in the order they are checked: 401 without a valid key; 403 scope_forbidden without traces:write; 404 feature_disabled while a required flag is off; 403 team_required for a key without a team; 429 rate_limit_exceeded past a requests-per-minute policy. The key is checked before the flags: a caller without a key, or with a key that lacks the scope, gets the same 401 or 403 whether the ingest is on or off, and only a key that holds traces:write is told that it is off. Also 503 rate_limit_unavailable when the rate counters cannot be read, and 503 storage_unavailable when the spans could not be stored (nothing of the upload was kept; send it again).

Symptom Check
A run is not recognized Is enabled true in the effective settings? Is the request made with a key, on a Chat Completions, Messages, Responses or generateContent route? Does a rule match what the client sends: compare the request’s User-Agent and headers with the rule (the client may have changed them in a new version, or a proxy in front of the gateway may strip them). A key without a team is labelled but not listed
One run is listed as several For a derived run: digest_key: process (configure a provider encryption key or a session key), a client that changes its system prompt or first message mid-run, or a compaction (the continued run is named only with one candidate). For any run: the session crossed two keys of different teams
Two runs are listed as one A derived run: both began with the same first message under the same key and system prompt, and either ran at the same time or the database did not answer the generation read (two runs that begin identically). Have the client send a run ID (a rule with run_headers), or declare X-Gateway-Session-Id
A run ID ends in -g2, -g3, … A derived run that began like an earlier one of the same key: each is a run of its own (two runs that begin identically)
The task is not captured (task.state is hash_only) task_capture_state in the settings; then the team’s content capture policy: it must exist, not be disabled, keep requests, and cover the run’s first call (its key, model and operation, when the policy lists them). A policy with a sample_rate below 1 keeps the task of that share of the runs. Only the call that begins a run can keep the text, so runs recorded before task capture was on keep the hash. A text that expired or was erased also reads hash_only
The task is withheld (task.state is withheld) You need content_sent:read of the run’s team. With content_capture turned off, kept text is withheld from everyone
Tool names are hidden You need content_structure:read of the run’s team, in the thread and in the trace view alike. A name that is not an identifier is never recorded. A tool step’s span is named client tool (or transcript tool) for every reader: search by the sub-kind, not by the tool’s name
A run counts fewer turns or tool steps than the client made A request answered with status 400 or above adds an error only. A tool whose result never came back in a later request is not seen. More than max_tool_steps new steps in one request are counted but not drawn
POST /v1/traces answers 429 The upload is past a requests-per-minute policy of its key, team, organization or end user, shared with the key’s model calls. Wait for Retry-After, or raise the policy
POST /v1/traces answers 413 trace_too_large The session’s trace already holds 2,000 spans. Start a new session; the spans stored so far stay
A run has no steps The span store did not keep them: span_store was off, spans.sample_rate sampled the requests out, or they are older than spans.retention_days. The run’s counters still come from the registry
A subagent is listed as a run of its own The client names no parent and inference did not apply: another key, a start later than the parent’s report (an asynchronous spawn), or outside link_window_minutes
POST /v1/traces answers 404 agent_transcript_ingest, agent_recognition, agent_sessions, session_tracking and span_store must all be on. Only a key that holds traces:write gets this answer
Every uploaded span is rejected Each span needs gen_ai.conversation.id and one of the four operations; IDs must be hexadecimal; times must be inside the span retention
  • Recognition reads what the client sends. Headers and fixed texts are the client’s to change; a rule is verified for the version it names.
  • Labels, not proof. A run ID and an agent name are asserted by the caller. They never authenticate, authorize or bill; quotas and budgets ignore them.
  • Tool steps are reported, never observed, and only for tools whose result came back in a later request through this gateway.
  • Derived runs can merge or split, as described under a derived run ID. Two runs that begin identically are told apart by the request that begins each; two such runs of one key going on at the same time, and a first message sent again unchanged after its answer, cannot be (two runs that begin identically).
  • Inferred links need the same key and a synchronous spawn.
  • A tool step is counted once, by its call ID, among the latest 256 the run counted. A request answered with status 400 or above adds an error and no turn or tool step. A result without a usable call ID counts only when it follows the model’s last message.
  • The task is fixed when the run is first recorded. A run first seen through a compaction or a helper call gets its task hash from the first later call that shows one. The task text is kept only from the call that begins the run.
  • A deletion of captured content narrowed to one request does not remove task text. The team-wide deletion and an end-user deletion do (task capture).
  • The run write happens after the answer, off the request path, bounded to 1.5 seconds. A failed write is logged (agent_run_record_failed) and loses that request’s contribution to the run’s counters; the request and its span are not affected. The one read a derived run adds to the request path is described under two runs that begin identically.
  • A thread reads at most the latest 1,000 spans of a run and the steps of the run plus its first 19 branches; open a branch to read its own.
  • No migration of old traffic. Requests served before the flag was on are not grouped into runs.

Migration 220 creates gateway_agent_runs. Both flags are off by default, and with them off nothing changes: no request is read, the run list, the thread and POST /v1/traces answer 404 feature_disabled, and the traces:write scope does nothing. Turning agent_recognition off again stops recognition at the next request; the stored runs are kept until their retention.

m7gtwcontact@m7gtw.com