Repository navigation
Open
Labels
enhancementNew feature or request
Description
Part of #1920.
Problem
agentop export and GET /v1/export (#1830, #1831,
core/sessionexport) write a content-free NDJSON record per event, by design
(#1854, R7). Replay tools need the content and a format they already load:
- Inference-Perf wire JSONL: one line per call, with the raw request,
the raw response or SSE, status, start time and duration. See
kubernetes-sigs/inference-perf,datagen/replay/wire_trace_converter.py. - OTel GenAI semantic conventions, as Inference-Perf's OTel replay and
our evaluators load them.
The archive already holds every field these need (the raw capture, ttfbMs,
durationMs).
Proposal
- A content export, separate from today's content-free path, writing wire
JSONL or OTel GenAI per session. - Local only, and redacted by default (feat: Redact recorded content before it leaves the archive #1921). It writes the session id
explicitly, because Inference-Perf reads it fromsession_id,
x-client-request-idorx-litellm-session-id, and not from
X-Claude-Code-Session-Id. - Include prompts (feat: Group a session's model calls into user prompts, in the recording and the timeline #1922) and Claude Code telemetry (feat: Add Claude Code telemetry to a recorded session: tool times, permission waits, call labels, retries #1924) when present.
@mrsabath: #1854's R13 says content "is refused by an export path rather
than offered as a flag". How should a content export sit next to it: its own
command or route, or a Tier 3 section in the spec? We'd also build on #1906
(session names, tool names, listing the archive).
Proposal (agreed with Hai, 2026-11-17): format and disk
Storage stays the archive's block-dedup segments. Wire JSONL and OTel are
generated only on export, and compressed.
Out of scope
- Uploading or sharing exports.
- Changing the content-free NDJSON record.
- Replay itself (feature: lossless capture in the session archive, so past sessions can be replayed to test a change before turning it on #1494).
Assisted-By: Claude (Anthropic AI) [email protected]
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Type
Projects
- StatusShow more project fieldsNew/ToDo
Activity
michaljacovi commentedon Nov 17, 2026
Design input from @mrsabath (Slack, 2026-11-17):
agentop exportor a?content=1on/v1/export. docs: Spec the session event export #1854 R13 rules out a flag; it doesn't rule out a content export elsewhere. Today's export stays shareable because it never has prompts, and a separate verb keeps that unconditional.Assisted-By: Claude (Anthropic AI) [email protected]
Docs: Add the gap split and the collection/export boundary to the spec
Docs: Spec the toolCall export record, and correct the per-tool laten…
michaljacovi commentedon Nov 22, 2026
A draft for discussion, building on #2009 and #2041, with redaction from #1921 (first PR: #2068). Comments welcome, especially on the open items at the end.
Content export: a session's exchanges in replay formats, design
Status: draft.
Date: 2026-11-22.
Issue: #1925 (part of #1920).
Parent specs:
2026-11-13-session-event-export-design.md(the content-free export; its R13 and §7.3 stay as they are) and2026-11-19-tool-call-export-record-design.md(thetoolCallrecord and the shared pairing).Background: #1921 (redaction), #1922 (prompt grouping), #1923 (opt-out), #1924 (Claude Code telemetry), #1997 (
sessionIncarnation).Decided on #1925: the content export gets its own command and its own route, not a flag on
agentop exportor/v1/export; the route refuses non-loopback callers; and it gets a spec of its own, because wire JSONL and OTel are not the content-free record's schema.Items marked Open must be decided before the work they belong to begins. Requirements are numbered C1 to C30, so they can be cited beside #1810's R-numbers and #1906's T-numbers.
1. Goal
Not goals: uploading or sharing an export; consent flows; replay itself (#1494); changing the content-free
eventortoolCallrecords.2. What exists
GET /v1/sessions/{id}/events/{seq}?raw=1reads one.durationMsandttfbMsare on the event.core/session/toolpair(Refactor: Share the tool-call pairing between the timeline and the export #2041).Callspairs each call with its result by tool-use id and closes the five no-result cases.CallcarriesStart,End,EndReason,CallSeq,ResultSeq,CallIndex,SiblingN,ModelDurandResultBytes, andArgumentsonly whenOptions.Argumentsis set.GET /v1/exportandagentop export, with theeventrecord (feature: export session events for post-processing — content-free per-event projection, NDJSON sink, archive-replayable #1810) and thetoolCallrecord (Export API: let a record name its session, carry tool names, and list the archive #1906 §2). Unchanged here.POST /v1/ingestrefuses non-loopback callers, and this route uses the same check.3. Requirements
3.1 Surface
C1. A separate command,
agentop export-content(Open: the name), with:--format wire|otel, defaultwire;--session <id>[,<id>...], required in version 1;--since,--out <path>(default stdout), and--redact <profile>and--raw(§3.4).C2. A separate route,
GET /v1/content-export?format=…&session=…&since=…&redact=…(Open: the path). It is not under/v1/export, so nothing reading one can mistake it for the other.C3. The route answers 403 to a non-loopback caller, whatever the bind address.
C4. Neither the content-free command nor its route gains a content flag. A test pins that
/v1/exportnever carries a body field (it extendsTestRecord_CarriesNoContent).3.2 Model calls
C5. One wire line is one model call: an inference request and its response. Tunnel rows, MCP and A2A calls are not lines in version 1 (Open).
C6. Wire JSONL follows Inference-Perf's
wire_trace_converterinput. Each line has:path, e.g./v1/messages;request: the forwarded request body, as an object;response: the raw response body, or the SSE text exactly as the upstream sent it;status;start_unix: the request time, in seconds with a fraction;total_ms: the event'sdurationMs;model;headers:{"session_id": <session id>}. Inference-Perf reads the session id fromsession_id,x-client-request-idorx-litellm-session-id, never fromX-Claude-Code-Session-Id;wire: "anthropic"for an Anthropic call.C7. Cortex's own fields sit under one
cortexobject, named as the content-free records name them:seq,ttfbMs,agentRole,client, the token splitinputTokens,outputTokens,cacheReadTokens,cacheCreationTokensandreasoningTokens(disjoint, as feature: export session events for post-processing — content-free per-event projection, NDJSON sink, archive-replayable #1810 R19),promptIndexwhen feat: Group a session's model calls into user prompts, in the recording and the timeline #1922 exists,sessionIncarnationwhen feature: Derive sessionIncarnation — split a reused session id into sittings #1997 exists, andredactions(counts by category, §3.4). Inference-Perf ignores the object. Open: a nested object, or flatcortex*keys.C8. The model-time number is the event's
durationMs: the same valuetoolCall.modelMscopies for the response that asked for a tool (Export API: let a record name its session, carry tool names, and list the archive #1906 T23).3.3 Tool calls
C9. Tool calls are paired by
toolpair.Calls, never by a second implementation. The content export calls it withOptions.Argumentsset, because this export carries arguments.C10. OTel GenAI has one trace per session and these spans:
chatspan per model call, withgen_ai.request.model,gen_ai.response.model, thegen_ai.usage.*token counts including cache,gen_ai.response.finish_reasons, andgen_ai.input.messages/gen_ai.output.messages;execute_toolspan pertoolpair.Call, withgen_ai.tool.nameandgen_ai.tool.call.id, the arguments and result (redacted, §3.4);Open: which conventions version to pin, and OTLP JSON or Inference-Perf's
spansshape.C11. A tool span's times and attributes come from
toolCall(#1906 §5), not from new definitions:startedAt, the asking response's end; end isstartedAt + durationMs, and absent whenendReasonhas no end;cortex.endReason,cortex.callSeq,cortex.callIndex,cortex.resultSeq,cortex.parallelN,cortex.durationShared,cortex.gapMs,cortex.gapKind,cortex.resultBytes.C12. A tool span's duration is a client round trip, not an execution time (Export API: let a record name its session, carry tool names, and list the archive #1906 §3.5): it includes any permission prompt and the person's answer. The span says so. With feat: Add Claude Code telemetry to a recorded session: tool times, permission waits, call labels, retries #1924 telemetry present, the blocked-on-user time is a child span, so a consumer can subtract it.
C13. The calls of one batch share one window (
durationShared). A consumer must not sum their durations as if each had its own; the export marks them and does not split the window.C14. The wire format has no tool lines, because Inference-Perf replays model calls. Each wire line lists the tool calls its response asked for in
cortex.toolCalls, each{callIndex, tool, durationMs, endReason}, so a replay can still see the tool time between calls.3.4 Redaction
C15. Every content field passes through the content redactor (#1921) by default, with the configured profile:
request,response, thegen_ai.*.messages, tool arguments and results, and error messages.C16. The rules see decoded string values, never raw bytes, so a match cannot cross a JSON quote or an SSE line.
data:URIs) are skipped by JSON path and counted, not scanned. A secret inside an image or an attached PDF is not found.C17.
cortex.redactionscounts what was redacted, per category, and never carries the redacted values. It also counts the skipped binary data and the thinking blocks with a redaction (C17a).C17a. Thinking signatures. A redaction inside a thinking block makes the block's signature invalid, so an export holding one cannot be resent to Anthropic as prior turns. Proposed: document it; count the affected blocks in the stats; and mark each affected call (
cortex.redactedThinking, the indexes of its affected blocks) so a replay tool can drop those blocks. Optionally, a flag to drop redacted thinking blocks from the export. Open: item 8.C18. Raw (
--raw, orredact=noneon the route) skips redaction. Open: allowed at all? Proposed: only on the loopback route, only with the explicit flag, and the command prints a one-line warning.C19. Request headers are never exported, other than the session id (C6).
3.5 The opt-out
C20. A withheld session (
noRecord, #1923) exports nothing after its opt-out: the archive holds nothing there. What it held from before the opt-out exports as usual. A session that is only a marker exports no lines, and the command says so on stderr.3.6 Data rules
C21. Durations are integer milliseconds, except
start_unix, which is seconds with a fraction because Inference-Perf reads that.C22. A value the archive did not record is absent, never zero (#1810 R17).
C23. Order is by
at, thenseq(#1810 R23). A retry is its own line.C24. A call the archive holds without a capture is exported with
requestandresponseempty andcortex.capture: "missing", never left out. That covers a capture dropped for the capture budget, and an imported event, which has no capture.3.7 Size
C25. Output streams, one line at a time (#1810 R5, R6). Each line repeats the conversation so far, as the wire format requires; the archive's block dedup is not visible in the output.
C26.
--outwith a.gzor.zstextension compresses as it writes, and the route honoursAccept-Encoding: gzip. Open: the default without an extension.4. Tests
C27. Golden files for both formats, from a short Claude Code session: a tool loop, a parallel batch, a subagent, a retry. The tool spans must match
toolpair.Callson the same events, field for field.C28. A planted-secret test, in the style of
TestRecord_CarriesNoContent. A secret is planted in every content field: request JSON, an SSEdata:line, a tool argument, a tool result, JSON inside JSON, a\u-escaped name, an error message. A secret split across SSE deltas is planted as well. The default export contains none of them, every JSON line is still valid JSON, and the SSE events are as many as before;--rawcontains all of them.C29. Behaviour tests:
C30. A dev-only check, not in CI, that Inference-Perf's converter loads the wire output: the same session, calls and token counts.
5. Delivery
cortex.toolCallsfromtoolpair, and the golden tests. Until feat: Redact recorded content before it leaves the archive #1921 lands it refuses to export unless--rawis given, so no unredacted content is exported by default.execute_toolspans fromtoolpair.promptIndex(feat: Group a session's model calls into user prompts, in the recording and the timeline #1922) and the telemetry spans (feat: Add Claude Code telemetry to a recorded session: tool times, permission waits, call labels, retries #1924), each when its source exists.6. Open items
agentop export-contentand/v1/content-export?cortexobject, or flat keys (C7)?spansshape, and which conventions version (C10)?cortex.redactedThinking, or another name)? And is a flag to drop redacted thinking blocks wanted?Assisted-By: Claude (Anthropic AI) [email protected]