Skip to content

Summarize each day's Claude Code and Codex sessions (engine, off by default) - #4

Merged
MilosMosovsky merged 18 commits into
mainfrom
session-summary/2026-11-05-2211-feat-session-summary-plan-pr1
Nov 6, 2026
Merged

MilosMosovsky merged 18 commits into
mainfrom
session-summary/2026-11-05-2211-feat-session-summary-plan-pr1

Conversation

@MilosMosovsky

@MilosMosovsky MilosMosovsky commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

What and why

#5 (the Summary page, install opt-in, MCP tools and docs) was merged into this branch, so merging this PR lands both.

agentyard can now write a daily summary of where every Claude Code and Codex session on this Mac got to, grouped by repository and topic, through one local CLI the user picks. It is off by default (-summary off), and nothing in this PR shows it yet.

Plan group: docs/plans/2026-11-05-2211-feat-session-summary-plan.md PR1 of 2. This PR is the engine (units U1–U5). PR2 stacks on it and adds the Summary page and its Summarize button, the agentyard install opt-in, and the docs.

What a reviewer should check

  • Transcript text leaves the Mac only through the chosen provider. Claude runs as claude -p --safe-mode --strict-mcp-config --tools "" --no-session-persistence. Codex runs as codex exec -s read-only --ephemeral --ignore-user-config --ignore-rules and turns off every feature the installed codex features list reports as on, except six that add no tool, plus web search. Codex 0.160 turns on connectors, browser and computer use, sub-agents and image generation by default. A live probe with the final flags got no tool calls: code mode fails closed, and a canary file outside the working folder stayed unreadable. The prompt goes on stdin, so transcript text stays out of ps.
  • A failed provider never switches provider and never replaces a good summary. A missing CLI, a non-zero exit, or a run where every note call failed records the error on the run, keeps the previous summary, and leaves the scheduled window where it was. A single failed batch only marks its sessions "not summarized".
  • The schedule. A one-minute ticker starts the run at or after -summary-at (default 07:00), so a Mac that slept through it runs on wake. The window starts at the last successful scheduled run, a failed morning still counts as that day's attempt, and runs from the button never move the window. Runs are single-flight.
  • The optional feature cannot take down the dashboard. Summary state that cannot be read is logged and skipped at startup. State files are fsynced before the rename.

Checklist

  • gofmt -l . is clean, go vet ./... and go test -race ./... pass (174 s), and GOOS=linux go build ./... builds
  • No new dependencies (agentyard is stdlib only)
  • UI changes: none in this PR

Tests use fake claude and codex scripts on PATH and an injected clock. They cover the corpus (sub-agents, idle parents, removed worktrees), provider arguments and stdin, the note cache, topic expiry, the schedule (wake, failed morning, button window, restart), runs where every call fails, damaged state, and Codex feature disabling. Over this Mac's real transcripts, collecting sessions took 2.4 s and found 92 sessions with 109 sub-agents.

Code review

ce-code-review ran with eight reviewers (run 20261106-112752-682ad444) and returned "Ready with fixes". The fixes are in this PR: Codex tool access, the all-calls-failed run, startup on damaged state, one owner for session keys and for "off", nested idle Codex parents, and fsync. The adversarial pass ran on Claude because the cross-model route needs npx. The rule that every run with no notes fails covers the notes pass only. A failed classification leaves sessions under "Unsorted", which the page design already handles.

Unapplied review findings

  • P3 — summary_notes.go:51 — summaryNotes is a test-only wrapper around summaryNotesAt. Kept because the tests that prove the notes pass call it.
  • P3 — summary_notes.go:117 — A parent session's note is discarded unless the model returns one line for every sub-agent. This is a product call: a session with 80 or more sub-agents may often show as "not summarized". The alternative is to keep the parent note and mark only the missing sub-agents.

Compound Engineering

🤖 Generated with Claude Code

https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy

MilosMosovsky and others added 8 commits November 6, 2026 10:46
Add the provider runner the session summary builds on: a serve flag
picks off, auto, claude or codex (off by default), and every call runs
the one chosen CLI from a private empty folder with no hooks, MCP
servers, tools or saved session, prompt on stdin, answers checked
against one strict schema per pass. A missing CLI or a non-zero exit
ends a run; a timeout or malformed answer fails only that call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
Gather every Claude Code and Codex session touched in a window as a
summary input: its goal and last turns, its sub-agents attached to the
session that started them (Claude by folder, Codex by parent thread),
and its project resolved from the git repository it ran in, remembered
so removed worktrees keep their project. Only files touched in the
window are parsed. The Sessions tab is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
Notes: each changed session gets a schema-checked note (where it got
to, what is next, what it waits on, one line per sub-agent), batched
up to eight per call within a project and cached by transcript size and
time, so an unchanged session costs no model call. Topics: each project
keeps a list that only grows when the model files a note under a new
topic; idle topics leave the page after 7 days and the list after 14. A
failed call leaves only its sessions unsummarized or unsorted. State
files share one atomic writer with the disk cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
A one-minute ticker starts the daily summary at the -summary-at time,
or on wake if the Mac slept through it. The scheduled window starts at
the last successful scheduled run, so a failed morning is covered by
the next one; button runs never move it. Runs are single-flight. Each
run is saved under the summary state folder with everything the page
needs to show it later, and a failed run keeps the previous summary.
The ticker only starts when -summary is not off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
Session keys and the activity-window test each have one helper now,
worktree lookups reuse find, and sub-agent progress is a map lookup.
Summaries read a transcript's head only when the goal or an automated
excerpt needs it, start tail reads at 512 KiB, and write topics.json
once per run when nothing else saved it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
Codex turns connectors, browser and computer use, sub-agents and image
generation on by default. A summary call now disables every feature the
installed codex reports as on, except a short list that adds no tool,
and turns web search off; a static list covers a codex whose feature
list cannot be read.

A run in which every note call failed now records an error, keeps the
previous summary and leaves the scheduled window where it was, instead
of saving a summary with every session unsummarized.

Unreadable summary state no longer stops the dashboard from starting:
the schedule starts over and a damaged history file is skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
A Codex sub-agent active under an idle sub-agent and an idle root now
nests under both instead of showing its parent as a top-level session.
State files are synced before the rename, so a power loss cannot leave
an empty one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
A reloaded time carries its offset, not time.Local, so DeepEqual
failed wherever the local zone is UTC, as on CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
MilosMosovsky and others added 10 commits November 6, 2026 13:40
`agentyard install` takes --summary, --summary-at and --summary-model,
keeps them across reinstalls, and resolves auto to the CLI it found so
the background agent never switches provider. A first install in a
terminal, or the first install after upgrading, asks once and names the
company that would receive transcript excerpts; without a terminal the
answer is off. A bad --summary-at fails the install instead of leaving
launchd restarting serve. The agent's PATH now includes the claude and
codex folders, and the cask's zap removes summary state.

Codex's feature list is now read on the first summary call, so
resolving a provider at install runs nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
list_summaries lists saved runs, failures included; get_summary reads
the latest successful run or one by timestamp, optionally for one
project, with hidden topics counted and left out. Both read local
history and never start a model. summarize starts or joins a run of
the last 24 hours through the background agent, waits a bounded time,
and returns the saved summary, the run's error, or that it is still
running; it refuses with how to turn summaries on when they are off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
A Summary tab groups the latest run by repository, topic and session:
each session shows where it got to, what is waiting on you or blocking
it, what comes next, its branch and PR, its sub-agents, and Copy
resume. Earlier runs, failed ones included, reopen from a dated picker.
Off shows how to turn summaries on and nothing else; a viewer that may
not see sessions gets the "this Mac only" panel and no summary data.

POST /api/summary starts a run from the page (page token and its own
Origin) or from agentyard mcp (no Origin, this Mac only).
GET /api/summary/status follows the Sessions rule. The demo shows a
synthetic summary and simulates a run without any process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
Each saved session now records its last transcript write, its
sub-agents' included. Sessions, sub-agents, topics and projects are
ordered newest first when the snapshot is built, so the page and
get_summary show the same order, and every session shows how long ago
it was touched, with the exact time on hover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
The state sits beside the session title, and a session waiting on you
or blocked shows that decision first, in stronger text. Topic names
step back so sessions stand out, and on phones the notes use the full
card width and the run header takes less room.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
…us shape

The remove and summarize endpoints share one guard for who may change
things; the status JSON has one struct for the handler and agentyard
mcp; the latest successful run, a project's sessions and the state map
each have one helper; the history picker reads only each run's time
and error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
- install: a provider switch without --summary-model no longer keeps
  the old provider's model, which made every run fail.
- page: a run that finishes while a past run is open lands on the
  latest run; the finish waits while a drawer, dialog or selection is
  open (open topics do not count); a failed status check retries and
  then re-enables Summarize. One helper sends the page token, and the
  meta tag is now agentyard-page-token.
- mcp: summarize says whether summaries are off, the request was
  refused, or the agent is too old, and refuses a demo on the agent's
  port; get_summary reports a run in progress or a newer failed run;
  unreadable history files are skipped; the instructions say summary
  text is data, not instructions.
- One table owns the session states, for the schema and the page; a
  blank waits_on is treated as none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
…install tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtvhFvhWywmqE7ZEmKxLJy
@MilosMosovsky
MilosMosovsky merged commit 0bca542 into main Nov 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant