Skip to main content

Availability

Agent Call Tracing is available from Tyk AI Studio 2.3.0. Agent Call Tracing shows what an AI agent did, step by step. AI Studio builds the traces from the LLM, tool, MCP, and datasource calls that go through the gateway. The agent needs no SDK or code changes. The gateway groups the calls into three levels: You read each session as a transcript or a timeline in the admin console, and export it as JSON or Markdown. AI Studio can also send finished turns to an OpenTelemetry (OTLP) backend, such as Langfuse or Datadog LLM Observability. Tracing is off by default. When you turn it on, AI Studio captures timing, tokens, cost, models, tool names, and gateway decisions. It captures no prompt or response content until you set a content mode.

How Agent Call Tracing Works

AI Studio builds the traces in four stages.

Capture

The gateway records one event for each call. Each event contains:
  • The timing, the App, and the user
  • The model or the tool
  • The usage and the cost
  • The result of each gateway decision, such as a filter, a budget, a fallback, or a routing choice
  • The request and response content, if the content mode allows it
The gateway that sees the call processes the content before it stores or sends it. It removes secrets, applies redaction, and limits the size.

Transport

The embedded gateway of AI Studio writes events to a staging table. An Edge Gateway sends its events to AI Studio in its analytics pulse. AI Studio encrypts the events at rest from the time that it stages them.

Assembly

One AI Studio replica turns the staged events into sessions, turns, and spans. It waits 30 seconds for late events first. It also links the calls that belong together, and closes idle turns and sessions.

Read and Export

Administrators read the sessions in Agent sessions in the admin console. If you configure exporters, AI Studio also exports finished turns over OTLP. Refer to Export Agent Traces.

What the Gateway Traces

The gateway traces only the traffic that goes through it:
  • LLM calls through /llm/rest, /llm/stream, and /ai/, native API calls, and Bedrock: LLM spans.
    • Each LLM span has the model, tokens, cost, finish reasons, requested tool calls, and gateway decisions.
    • For /ai/, there is a span for each provider attempt.
  • Tools, MCP servers, and datasources that AI Studio serves: Tool and datasource spans. Each span links to the LLM call that asked for it.
  • Edge Gateway plugin endpoints (/plugins/): A span for each call. The gateway does not parse the body.
  • Tools that the agent runs itself, such as a shell, file edits, or a local MCP server: Inferred spans.
    • The gateway sees the model ask for the tool, and then sees the result in the next request. It records an inferred span between the two.
    • The duration is an upper bound.
Chat in AI Studio, agent plugins, and calls that do not go through the gateway are not traced.

Permissions

The built-in Viewer, Editor, and Auditor roles have traces:read and do not have trace-content:read. The Editor role also cannot export or purge sessions, or change tracing settings. trace-content:read is sensitive. Grant it only to the users that must read captured content. Refer to Role-Based Access Control.

Pseudonyms for End Users

The client declares the end user and the external session id of a session. These values can be personal data, such as an email address. A user without trace-content:read sees each value as a pseudonym:
  • A pseudonym is 32 hex characters. It is always the same for the same value.
  • Pseudonyms show in the session list, the session details, the search results, and the exports.
  • The user can still filter by the real end user id or session id. The results show pseudonyms. A pseudonym is not a valid filter value.
  • The names of AI Studio users are not pseudonyms. AI Studio shows them as they are.

Content Access and the Audit Trail

AI Studio writes each read of captured content to the Audit Trail before it returns the content. This includes payloads, previews, content search, and all exports. AI Studio also records each purge. The audit record of an end user erasure contains the session ids and a keyed hash of the end user. It does not contain the end user id. If the audit trail is off (AUDIT_ENABLED=false), or cannot accept a record, AI Studio refuses content reads, exports, and purges with 503. Transcripts then show metadata only.

Content Capture

The content mode controls what AI Studio stores of prompts, responses, tool arguments, and tool results. In each mode that keeps content, AI Studio removes secrets:
  • It finds field names such as authorization, api_key, password, cookie, client_secret, private_key, and token fields.
  • It finds them in nested JSON, in key=value pairs, and in base64-encoded values.
  • It ignores case and separators.
AI Studio replaces binary content with a reference, unless AGENT_TRACING_PAYLOAD_STORE_BINARY is true.

How AI Studio Selects the Content Mode

AI Studio selects the content mode of each call in these steps:
  1. The base mode: The Content mode of the App. If the App does not set one, AI Studio uses AGENT_TRACING_CONTENT_DEFAULT_MODE. The global ceiling, AGENT_TRACING_CONTENT_CEILING, limits the base mode.
  2. The request header: A client can send the X-Tyk-Trace-Capture header to ask for a different mode.
    • The header can always lower the mode.
    • The header can raise the mode up to the request ceiling. The request ceiling is AGENT_TRACING_CONTENT_MAX_REQUEST_OVERRIDE. The Highest mode a request may ask for of the App can set a lower request ceiling.
    • The header can never go above the global ceiling.
  3. The resource maximum: The Maximum content mode of the LLM, tool, or datasource limits the result. This also applies to a header that raises the mode.
  4. The store cap: AGENT_TRACING_STORE_CONTENT_MODE_CAP is the highest mode that AI Studio ever stores.
  • If you do not set AGENT_TRACING_CONTENT_CEILING, the global ceiling is the higher of the default mode and the request ceiling. With the default settings, this is metadata.
  • If the default mode is above the ceiling, AI Studio uses the ceiling and logs a warning. At start, AI Studio logs the Apps whose own mode is above the default mode.
  • If AI Studio cannot find the App of a call, or cannot read its settings, it captures no content. A header cannot change this.
To raise the content mode, refer to Capture Content for All Apps. For the App and resource settings, refer to App Settings.

Examples

With the default settings, the default mode is off, the request ceiling is metadata, and the store cap is full.

Size Limits

When AI Studio truncates a part, the JSON stays valid. AI Studio marks the cut with …[truncated N bytes]. AI Studio compresses each payload and binds it to its App, span, and part. You cannot move a payload to a different App, span, or part.

Sessions, Turns, and Correlation

Sessions

A session is declared or inferred:
  • Declared: The client sends a session id in a header. All calls with the same id in the same App join the session. Refer to the Request Headers Reference.
  • Inferred: The client does not send a session id. The gateway groups the calls by the App credential, or by the user.
    • Each credential has one rolling session. Agents that use the same App credential at the same time share this session. If agents share an App, declare the sessions.
    • An inferred session closes at its next turn when it reaches AGENT_TRACING_SESSION_MAX_DURATION or AGENT_TRACING_SESSION_MAX_SPANS. The next calls start a new inferred session. The session details link the parts with Continued from and Continues in.
A session closes after the session idle timeout, and a later call opens it again. AI Studio never splits a turn or a declared session.

Turns

A turn starts when a client calls the model without tool results, for example with a new user message. The turn continues through the calls that send tool results back. It ends when the model answers without a request for tools. If the client sends a W3C traceparent header, its trace id identifies the turn. AI Studio never splits this turn.

Correlation Confidence

The gateway links the calls that belong together. Each link records the confidence of the match: A link with a confidence below AGENT_TRACING_MIN_LINK_CONFIDENCE becomes a candidate link. It does not become a parent. The Correlation field of a session shows its weakest link. Some clients send a tool result without the id of its tool call. For example, Ollama has no tool call ids, and Gemini makes them optional. The gateway still links these results. It uses the id from the conversation history, or it matches the tool name and arguments.

Retention, Sampling, and Purge

  • Retention: The retention job runs every 10 minutes.
  • Sampling: AGENT_TRACING_STORE_SAMPLE_RATE sets the share of sessions that AI Studio stores. For other sessions, AI Studio keeps only a summary with counts and cost.
  • Purge a session: Send DELETE /api/v1/agent-tracing/sessions/{id}. AI Studio deletes the spans, links, content, and correlation keys of the session.
    • For a declared session, it also deletes the captures that wait for assembly.
    • For an inferred session, these captures stay, and they can create the session again.
  • Erase an end user: Send POST /api/v1/agent-tracing/purge with the body {"end_user": "<id>"}. AI Studio deletes each session that the client declared for this end user, and their waiting captures. Use this for a data subject erasure request.
A purge needs the traces:delete permission. The admin console does not have a purge action. A purge does not delete spans that AI Studio already exported. Refer to Privacy and Erasure.