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.
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) noreply@anthropic.com