Repository navigation
Description
Summary / PRD
AutoBot already captures rich institutional memory from coding-agent sessions that it spawns itself as an execution backend, and exposes that memory back to agents over MCP. This epic closes the one remaining capture gap: externally-initiated developer sessions — a person running Claude Code / Codex / Cursor on their own machine, outside AutoBot's execution loop — currently leave no trace in AutoBot memory. Their transcripts, tool calls, and decisions are lost, so a later agent (or the same developer) re-derives context AutoBot never learned.
The goal is a zero-friction, opt-in path that streams an externally-initiated coding session into AutoBot memory using the existing event → memory → MCP pipeline, so past external work becomes searchable via the tools we already ship.
What already exists (reuse, do not rebuild)
- Coding-session capture → memory:
services/execution/claude_code_backend.py(Issue feat(llm): Claude Code / Claude Agent SDK as an execution provider #10550) streamsACTION/OBSERVATION/MESSAGEevents into the event bus, which persists to memory. - Transcript parsing:
_parse_cli_line(claude_code_backend.py:123) decodes Anthropic content blocks (text/tool_use/tool_result). Anthropic-only today. - Event → memory persistence:
events/stream_manager.py,events/bus.py,events/types.py(AgentEvent,ActionContent,ObservationContent,MessageContent). - Cross-session memory:
memory/agent_diary.py,AutoBotMemoryGraph, VerbatimStore. - MCP read surface (query side is DONE):
mcp/autobot_server.py—memory.verbatim_search(supportssession_filter),memory.timeline,memory.related,agents.diary_summary,kb.search. - Embed reconcile:
background_vectorization.pyvectorize_pending_factsself-heals failed embeds (retry untilvectorization_status=completed).
The gap
- No ingestion path for a completed transcript produced outside AutoBot's execution loop (hook-driven, from a developer's own CLI session).
_parse_cli_linehandles a live Anthropic JSONL stream only — no Codex / OpenAI response-item format, and no batch/file (optionally gzipped) parsing.- No session read/list MCP tools to pull a full external session back (only verbatim chunk search exists).
Proposed solution (thin, reuses the pipeline)
- Extract the block-decoding logic from
_parse_cli_lineinto a sharedtranscript_normalizerthat accepts a whole transcript (JSONL, optionally gzipped) and yields the same event shapes, adding a Codex response-item branch.claude_code_backendthen imports the shared normalizer instead of its private copy (no behaviour change for spawned runs). - Add an authenticated
POST /api/sessions/ingestendpoint (owner-scoped) that accepts a transcript, runs it through the normalizer, and publishes the events through the existing bus so they persist to memory exactly like a spawned run. - Ship opt-in hook scripts (
on_session_end, etc.) that POST the just-finished transcript to that endpoint. Governed by an explicit env/config opt-in — off by default. - Add
memory.session_list/memory.session_readMCP tools over the existing session store so ingested sessions are retrievable, not just chunk-searchable.
Non-goals
- No new vector DB, embedder, or search stack — reuse ChromaDB + the existing RAG/rerank pipeline.
- No change to spawned-run behaviour beyond swapping the private parser for the shared one.
- No always-on capture — ingestion is opt-in per developer.
Tasks
- Task 1: Shared transcript normalizer → PR
- 1.1 Extract block decoding from
claude_code_backend._parse_cli_lineintoservices/execution/transcript_normalizer.py(pure, unit-tested against fixtures) - 1.2 Add Codex/OpenAI response-item branch + gzip/batch file support
- 1.3 Repoint
claude_code_backendat the shared normalizer; assert no behaviour change for spawned runs
- 1.1 Extract block decoding from
- Task 2: Owner-scoped ingestion endpoint → PR
- 2.1
POST /api/sessions/ingest(auth + owner scoping + size limits + SSRF/path safety); publish via existing bus - 2.2 Idempotency by session id (re-ingest is a no-op / update, mirror
session_service.upsertsemantics)
- 2.1
- Task 3: Opt-in hook scripts → PR
- 3.1
on_session_endhook that POSTs the finished transcript; env/config opt-in, off by default - 3.2 Docs: enabling capture + privacy note (local-only framing)
- 3.1
- Task 4: Session read/list MCP tools → PR
- 4.1
memory.session_list+memory.session_readover existing session store, behind thememoryscope
- 4.1
Acceptance criteria
- An externally-initiated Claude Code and Codex session, once ended, appears in AutoBot memory and is returned by
memory.verbatim_searchand the newmemory.session_read. - Spawned-run behaviour is byte-for-byte unchanged (normalizer swap is transparent).
- Capture is opt-in and off by default; endpoint rejects unauthenticated / oversized / cross-owner payloads.
Open decisions (owner input needed before Task 2+)
- Retention & privacy: how long are ingested external transcripts kept, and are they per-user private by default? (Affects endpoint + storage.)
- Redaction: do we scrub secrets/paths from external transcripts on ingest, and to what depth?
- Scope of formats for v1: Claude Code + Codex only, or also Cursor / Gemini CLI?
Task 1 (shared normalizer) and Task 4 (read tools) are safe to start immediately — they reuse existing seams and carry no product/privacy decision. Tasks 2–3 are gated on the decisions above.
Activity
mrveiss commentedon Jul 7, 2026
Owner decisions resolved (un-gates Tasks 2–3, sizes Task 1)
1. Retention & privacy → private-per-user, indefinite.
Ingested external transcripts are owner-scoped and not shared by default; no auto-purge. Storage growth + stale-content pruning is a follow-up, not v1 (file a discovery issue if growth becomes real). Sharing to a team is explicit opt-in via the existing share/publish path — never a default.
2. Redaction → route secrets through the existing secrets manager, do not scrub-and-drop.
On ingest, detected secret-like spans are stored in the envelope vault and replaced in the transcript with a secret reference placeholder, so plaintext secrets never land in memory or embeddings, while the vault manages user/team sharing. This reuses:
services/secrets_service.py(SecretsService,get_secrets_service()) +autobot_shared/secrets_vault.py(envelope vault, team-shareableVaultAccess) for storage.services/workflow_secret_service.py:240resolve_secrets(text, owner_id)already does reference → value; Task 1 adds the inverse capture (value → vault ref) so the same reference format round-trips.services/secrets_access_audit.pyfor access logging.This replaces the old "aggressive scrub" line item — no lossy redaction; content stays intact via references.
3. Formats → all four: Claude Code, Codex, Cursor, Gemini CLI.
Task 1 sizes to 4 parser branches + 4 fixture sets in the shared
transcript_normalizer, each yielding the canonicalAgentEventshapes._parse_cli_line(Anthropic) is the seed for the Claude Code branch.Revised task tree
claude_code_backend._parse_cli_lineintoservices/execution/transcript_normalizer.py; repoint the backend at it (no behaviour change for spawned runs)SecretsService(envelope vault) → replace with reference placeholder compatible withworkflow_secret_service.resolve_secrets; unit-test round-trip + audit logPOST /api/sessions/ingest(auth + owner scoping + size limits + path safety); runs normalizer → secret-capture → existing event bus → memorysession_service.upsertsemantics)on_session_endhooks for Claude Code / Codex / Cursor / Gemini that POST the finished transcript; env/config opt-in, off by defaultmemory.session_list+memory.session_readover the existing session store, behind thememoryscopeStatus: Tasks 1 & 4 unblocked and buildable now; 2 & 3 unblocked by the decisions above. No new vector/embedding/secrets infrastructure — all four tasks reuse existing modules.
mrveiss commentedon Jul 8, 2026
Correction — wire secret-capture to the canonical secrets store (#10088)
Follow-up audit note on the redaction decision above. The earlier comment named
SecretsService/autobot_shared/secrets_vault.pyas the storage target. The canonical entry point isservices/secrets_coordinator.pySecretsCoordinator— the RBAC-governed façade being standardised under umbrella #10088 ("unify AutoBot secrets — replaces 11 stores, 5 keys, 2 UIs"). Task 1.3 must target it, not the legacy service classes:SecretsCoordinator.create(...)(:78)SecretsCoordinator.share(...)(:135)Net-new scope clarified: existing helpers only handle known, registered secret names —
workflow_secret_service.resolve_secrets(ref→value, :240) andredact_secrets(:281). Task 1.3's new work is auto-detecting unregistered secret spans in an external transcript (pattern-based: API keys, bearer tokens,export KEY=…) →SecretsCoordinator.create→ replace with a${secrets.NAME}reference that round-trips through the existing resolver. Reuse the detection patterns, add the capture direction.Cross-link: secrets-store consolidation itself is out of scope here and owned by #10088 — this epic consumes the canonical coordinator, it does not modify the secrets architecture.
ajdelaguila commentedon Jul 9, 2026
Full disclosure: I maintain Data Olympus, a governed project-knowledge MCP server for coding agents: https://github.com/knaisoma/data-olympus
This external-session ingestion path is a strong fit for an authority/lifecycle split. Transcript capture can make institutional memory much richer, but raw transcript-derived facts should probably not become governing knowledge automatically.
A pattern that has worked well for us is:
Data Olympus focuses on that governed layer: markdown in git, MCP retrieval, proposed writes, accepted/in-force filtering, validity windows, and supersession chains. It may be useful as a reference for the part of this epic where transcript events become durable project knowledge rather than just searchable history.
The secret-capture correction in the latest comment also reinforces the same point: capture and retrieval need provenance and policy metadata close to the memory, otherwise it becomes hard to answer “why did the agent remember this?” or “is this allowed to influence this user/project?”
hegu-1 commentedon Jul 10, 2026
The hook-ingestion gap is real, but I would avoid making external sessions write directly into institutional memory.
A safer pipeline is four layers:
raw_hook_event: append-only capture from Claude/Codex/etc. with source, cwd, repo, branch, tool name, timestamp, and redaction state.normalized_session_trace: grouped run with goal, files touched, commands, test results, decisions, failed paths, and final outcome.candidate_memory: proposed reusable facts such as conventions, architectural decisions, recurring fixes, or environment gotchas.promoted_institutional_memory: reviewed memory that agents can trust in future sessions.That distinction matters because externally initiated sessions have mixed authority. Some traces are useful evidence; not all of them should become durable instructions. The ingestion boundary should preserve provenance, but promotion should be explicit and reviewable.
I have been working on a similar memory-vault pattern for personal and project AI continuity: trace is cheap to capture, but durable memory needs a promotion gate. This repo may be useful as a concrete reference: https://github.com/hegu-1/personal-ai-os
mrveiss commentedon Oct 17, 2026
@hegu-1 @ajdelaguila your design input is answered in #18657. The review step is now a requirement on this epic: #18656.
mrveiss commentedon Oct 25, 2026
Owner decisions, 2026-10-25: ingest our Claude Code history about AutoBot into the local AutoBot install, so historical decisions are searchable. Nothing leaves this machine. Build this issue now; run the actual ingest only after the KB read-path leak fix (#16665) is deployed, because session history is private.
Sources found (local only):
history.jsonl(prompt, project, timestamp)history.jsonlLoss to note: the previous dev machine's 837 full sessions (Jan–Apr 2026) were copied over on 2026-09-05 with their original timestamps, and Claude Code's default 30-day transcript cleanup deleted them. Retention is now 10 years (
cleanupPeriodDays: 3650), so nothing more expires. For that period, only the prompt histories remain.Scope additions to this issue:
history.jsonlprompt histories (prompt + project + timestamp → evidence entries).13 remaining items
chore(guards): re-pin the reach floors the pre-push gate reported sta…
fix(memory): every JSON parse is contained, the retained bound is rea…
test(guards): the collectable-modules floor comment states the popula…
mrveiss commentedon Oct 30, 2026
Findings from review of merge train PR #20083, recorded here as follow-ups:
autobot-backend/memory/verbatim_sessions.py:69: Real: Chroma get() with a limit is not documented to return newest-first, so past the scan cap the newest session can fall outside the scanned rows. The response does set truncated=true when the scan is cut, so the partial view is declared, not silent. Needs an ordering-safe scan (page through all owner rows, or keep a per-session index); tracked as a follow-up.autobot-backend/memory/verbatim_sessions.py:93: Real but narrow: if a later turn is stored before turn 0 and the session exceeds the chunk cap, the capped page can start mid-conversation. truncated=true is returned in that case, and chunks arrive in insertion order, so it needs out-of-order writes plus an oversize session. Tracked together with the session_list scan cap.autobot-backend/mcp_server/memory_session_tools.py:101: Accurate: the byte budget is charged on the redacted body, but the frame (warning text plus delimiters, a few hundred bytes per chunk) is added on top, so the response can exceed SESSION_READ_MAX_BYTES by a bounded amount (at most chunk-cap times frame size). Not unbounded; count the framed text instead of the body when charging.autobot-backend/mcp_server/memory_session_tools.py:100: Partly accurate: only the text is redacted and framed; metadata is copied as stored. The stored keys are session_id, turn, role, timestamp and user_id (verbatim_store.py:243-250), all written by or for the same owner, so the exposure is the owner's own session id and principal id echoed back, with session_id as caller-chosen text outside the frame. Low severity; return an allowlist (turn, role, timestamp) and drop user_id.autobot-backend/mcp_server/memory_session_tools.py:117: The mismatch is real by construction: reads are filtered on exact user_id, an MCP bearer resolves to a token-derived id (principal.py:40) and a run JWT to agent_id, while chat writes store the human user id. Binding principals to a writer identity is a design and authorization decision (it widens who can read whose history), so it needs a maintainer decision rather than a patch here. The fail-closed behaviour is the safe default meanwhile.autobot-backend/services/execution/transcript_normalizer.py:221: Confirmed inconsistency: _codex_item_event handles custom_tool_call and custom_tool_call_output, but the bare-record dispatch in normalize_codex_record lists only message, function_call and function_call_output, so a bare custom-tool line yields no event (wrapped response_item lines are fine). I could not confirm that bare custom-tool lines occur in real rollouts. Adding both types to the tuple is safe.autobot-backend/services/execution/transcript_normalizer.py:244: Partly inaccurate: a boolean timestamp already yields an empty value (_iso_from_epoch_ms returns "" for non-numeric, non-string input), sotrueis not retained. A present string is passed through unchanged by design, so "not-a-date" is kept as the entry's timestamp. Validating that string as ISO is optional hardening; low impact since the value is the user's own history.The item on which stored
user_idan MCP principal reads as is an authorization decision for the maintainer.github-actions commentedon Oct 30, 2026
Landed via the merge train (#20083, merge
f69c6a7d46) via #20033mrveiss commentedon Oct 30, 2026
The merge train (PR #20083), main f69c6a7, via #20033. 6 of 12 boxes ticked: Tasks 1 and 4.
services/execution/transcript_normalizer.pyhasparse_cli_line,normalize_codex_record, gzip initer_lines, andread_transcriptsfor batches.claude_code_backend.py_parse_cli_line = parse_cli_line.transcript_normalizer_test.py::TestSpawnedRunOutputUnchangedpins the decode results.mcp_server/memory_session_tools.py, mixed intoAutoBotMCPServer. Test:test_behind_the_memory_scope_only.Open: Tasks 2 and 3 (no
sessions/ingestroute onmain) and their open decisions. The issue's acceptance criteria need those, so it stays open.mrveiss commentedon Nov 1, 2026
Maintainer decision (2026-11-02): an admin binds each tool-server login to a named person, and that login reads only that person's history. Until a login is bound, reads stay refused. The authorization design follows here.
mrveiss commentedon Nov 20, 2026
Branch
issue-11137-session-normalizer(PR #20033, head 7ad4ed1) was deleted as a zero-change branch: its content is already on main. Tasks 1 and 4 were already ticked. Task 2 (owner-scopedPOST /api/sessions/ingest) and Task 3 (opt-inon_session_endhook plus docs) stay unticked: I found no ingest route or session-end hook script on main (searchedautobot-backend/api, scripts, docs).