You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Let a user keep one session out of the recording #1923
On a laptop the archive is on by default (#1639), and its switch is global: session.archive.enabled. To keep one sensitive session out, a user has to
turn the whole archive off, or delete the session afterwards
(DELETE /v1/sessions/{id}). listener.skip_hosts works per host, not per
session. Opt-out per session is what lets people leave recording on.
Proposal
When a session's requests carry an opt-out marker, nothing of that session
is written to the archive. The proxy still forwards it and runs its
plugins.
The session id comes from the existing headers (core/session/idheader.go).
Proposal (agreed with Hai, 2026-11-17): how the user sets it
Modelled on context-guru:
An env var at launch (CORTEX_RECORD=off) that becomes a request header
on every call of that session.
Optionally, a mid-session /no-record that stops recording and deletes
what was already written. It needs a "stop recording this session" call
into Cortex.
The exact shape of that call is a design detail for this issue's PR. It must
respect #1856's anti-goal of no API route that accepts events from a
caller: it only stops the archive for one session.
Open questions
Does an opted-out session still count in the cost ledger? Ledger rows carry
no content, so we'd keep them.
Is it shown in agentop at all (live only, marked "not recorded")?
Out of scope
Per-project or per-user defaults: a follow-up once the per-session switch
exists.
Design before the first PR. Three PRs, each useful on its own.
PR 1: the proxy honours X-Cortex-Record: off (named like the other X-Cortex-* headers)
ResolveClient pins Context.NoRecord() from the headers before any plugin runs, and removes the header from pctx.Headers. So plugins never see it, and SyncRequestHeaders doesn't forward it. sessionevent copies it into a new SessionEvent.NoRecord. Only off counts; anything else records.
The archive makes it sticky per session: from the first flagged event on, it withholds every event of that session, including header-less ones filed by process or client affinity (attribution.go). In a test session, Claude Code's Datadog and event_logging calls landed in the session without the header. Events archived before the first flagged one are erased. Flagged requests queue no capture.
The proxy still forwards the session and runs every plugin. The cost ledger and usage keep their rows, which carry no content.
The live view keeps the session in memory, with noRecord on its summary.
Finding: import after a restart.WriteSession refuses a live session only while the archive or this run's numbering knows the id (archive/import.go). An opted-out session leaves nothing in the archive. So after a restart, agentop import would bring it in from Claude Code's transcript. The fix: the archive keeps a content-free marker for the id (a session.json with noRecord: true and no segments). It survives restarts, and the import refuses that id. prune keeps the marker for retention_days after the session's last event, then removes it like any expired session.
PR 2: launch-time switch.CORTEX_RECORD=off agentop exec claude (or --no-record) appends the header to the child's ANTHROPIC_CUSTOM_HEADERS. Checked: Claude Code sends it on every inference call, main and subagent (3 of 3). A settings-file env block overrides the process env, so exec checks for an ANTHROPIC_CUSTOM_HEADERS there and warns. Claude Code first; the other agents later.
PR 3: mid-session /no-record. A UserPromptSubmit hook blocks the prompt (so it never reaches the model) and calls a new loopback-only POST /v1/sessions/{id}/no-record. That sets the same mark and erases what was already written, through the existing delete path. It accepts no events, like DELETE /v1/sessions/{id}.
Questions:
Is an event field plus the archive's sticky marker the right shape? Its other effect is that DELETE /v1/sessions (clear all) also clears the markers, so a later import could bring those sessions in.
Is a content-free marker in the archive OK? It records only that the id opted out, and lives retention_days.
Should the live store also drop parsed content for an opted-out session, or keep it for plugins as today?
Praxis mode (cortex-gateway → /v1/ingest): in PR 1, or a follow-up?
Not covered: Claude Code's startup calls go to pending:claude-code before the session id is known, so they're recorded as today. They are bootstrap calls (/api/claude_cli/bootstrap and two others), not the conversation.
Update to the design above, after two rounds of review on the PR 1 branch. Three changes, and one note on praxis mode.
1. Own session only. The flag counts only when the request names its own session with a session-id header. A request that names none is filed by fallback (to the active session or default), and honouring its flag there would stop someone else's recording. Such a request is recorded as usual; the header is still stripped. A header can also name a shared bucket (default, or a pending: one), so the opt-out applies only to ids that session.IsConversation accepts.
2. Never backwards. The earlier text said events archived before the first flagged one are erased. They are no longer erased: what the archive already holds for the session stays, and the opt-out applies from the first flagged event on. The session-id header is client-asserted, so a request naming another session must not be able to erase that session's history. Erasing stays explicit: DELETE /v1/sessions/{id}, and /no-record in PR 3.
3. The marker is stricter. Any marked session refuses an import, with or without replace, including one whose events were imported first. The first flagged event persists the marker at once (also while the archive is paused), so a restart before the next event keeps it. Renames carry it.
Praxis mode. The gateway records a hopped request, and its rows come back through /v1/ingest without the flag (the header is stripped before the hop). PR 1 handles that in Go: before it hops a request that withholds its session, the forward proxy marks the session in the store, which stamps that session's later events, ingested rows included. The store also tells the archive at once, so the archive's marker exists from the hop on, even if the store later evicts the session. A cleaner later option is a noRecord field in attribution.Wire that cortex-gateway copies into each row's event. That needs a change in praxis/. Would you prefer that as a follow-up?
The four questions above still stand, with question 1 now about the store stamp for ingested rows next to the archive's marker.
Activity
michaljacovi commentedon Nov 17, 2026
Design before the first PR. Three PRs, each useful on its own.
PR 1: the proxy honours
X-Cortex-Record: off(named like the otherX-Cortex-*headers)ResolveClientpinsContext.NoRecord()from the headers before any plugin runs, and removes the header frompctx.Headers. So plugins never see it, andSyncRequestHeadersdoesn't forward it.sessioneventcopies it into a newSessionEvent.NoRecord. Onlyoffcounts; anything else records.attribution.go). In a test session, Claude Code's Datadog andevent_loggingcalls landed in the session without the header. Events archived before the first flagged one are erased. Flagged requests queue no capture.noRecordon its summary.Finding: import after a restart.
WriteSessionrefuses a live session only while the archive or this run's numbering knows the id (archive/import.go). An opted-out session leaves nothing in the archive. So after a restart,agentop importwould bring it in from Claude Code's transcript. The fix: the archive keeps a content-free marker for the id (asession.jsonwithnoRecord: trueand no segments). It survives restarts, and the import refuses that id.prunekeeps the marker forretention_daysafter the session's last event, then removes it like any expired session.PR 2: launch-time switch.
CORTEX_RECORD=off agentop exec claude(or--no-record) appends the header to the child'sANTHROPIC_CUSTOM_HEADERS. Checked: Claude Code sends it on every inference call, main and subagent (3 of 3). A settings-fileenvblock overrides the process env, soexecchecks for anANTHROPIC_CUSTOM_HEADERSthere and warns. Claude Code first; the other agents later.PR 3: mid-session
/no-record. AUserPromptSubmithook blocks the prompt (so it never reaches the model) and calls a new loopback-onlyPOST /v1/sessions/{id}/no-record. That sets the same mark and erases what was already written, through the existing delete path. It accepts no events, likeDELETE /v1/sessions/{id}.Questions:
DELETE /v1/sessions(clear all) also clears the markers, so a later import could bring those sessions in.retention_days.cortex-gateway→/v1/ingest): in PR 1, or a follow-up?Not covered: Claude Code's startup calls go to
pending:claude-codebefore the session id is known, so they're recorded as today. They are bootstrap calls (/api/claude_cli/bootstrapand two others), not the conversation.Assisted-By: Claude (Anthropic AI) [email protected]
michaljacovi commentedon Nov 18, 2026
Update to the design above, after two rounds of review on the PR 1 branch. Three changes, and one note on praxis mode.
1. Own session only. The flag counts only when the request names its own session with a session-id header. A request that names none is filed by fallback (to the active session or
default), and honouring its flag there would stop someone else's recording. Such a request is recorded as usual; the header is still stripped. A header can also name a shared bucket (default, or apending:one), so the opt-out applies only to ids thatsession.IsConversationaccepts.2. Never backwards. The earlier text said events archived before the first flagged one are erased. They are no longer erased: what the archive already holds for the session stays, and the opt-out applies from the first flagged event on. The session-id header is client-asserted, so a request naming another session must not be able to erase that session's history. Erasing stays explicit:
DELETE /v1/sessions/{id}, and/no-recordin PR 3.3. The marker is stricter. Any marked session refuses an import, with or without replace, including one whose events were imported first. The first flagged event persists the marker at once (also while the archive is paused), so a restart before the next event keeps it. Renames carry it.
Praxis mode. The gateway records a hopped request, and its rows come back through
/v1/ingestwithout the flag (the header is stripped before the hop). PR 1 handles that in Go: before it hops a request that withholds its session, the forward proxy marks the session in the store, which stamps that session's later events, ingested rows included. The store also tells the archive at once, so the archive's marker exists from the hop on, even if the store later evicts the session. A cleaner later option is anoRecordfield inattribution.Wirethatcortex-gatewaycopies into each row's event. That needs a change inpraxis/. Would you prefer that as a follow-up?The four questions above still stand, with question 1 now about the store stamp for ingested rows next to the archive's marker.
Assisted-By: Claude (Anthropic AI) [email protected]
fix: Keep the header-derived session id out of the archive's queue-fu…
fix: Let the archive's writer own the opt-out, and never drop a flagg…
fix: Never set X-Cortex-Record through ext_proc, and tighten the opt-…
fix: Deliver every flagged event and Withhold, below the reserve, and…
fix: Withhold an opaque CONNECT's own session, close the deliver/Clos…
fix: Keep an opt-out at its place in the archive queue instead of wai…
test: Cover a row queued while an opt-out is kept, and state the list…
Merge origin/main into record-optout-pr
docs: Document X-Cortex-Record and noRecord, and report failedClosed
Merge origin/main into record-optout-pr; guard the hop's opt-out
fix: List noRecord as a field the gateway never sets
feat: Keep a session out of the archive when its requests carry X-Cor…
feat: Add agentop exec --no-record for Claude Code
fix: Refuse --no-record for other agents, and check CLAUDE_CONFIG_DIR
fix: Use the short not-recorded mark when TITLE is too narrow for the…
feat: Mark a session that is not recorded in agentop observe