Relationships
#4621 Swampify: assess method in @swamp/agent-sessions mines transcripts into a candidate set
Opened by skunk-ape · 11/10/2026· Shipped 11/11/2026
Part of Swampify onboarding. Depends on #4606, which defined the candidate set this method writes (SwampifyCandidateSet v1, swampify.md in the extension).
Repo: swamp-extensions (@swamp/agent-sessions).
Goal
Add an assess method to @swamp/agent-sessions. It reads Claude Code transcripts and Codex rollouts on this machine and writes one swampify-candidates data item: the repeated chores worth automating, ranked, each with its evidence and per-occurrence cost. It is deterministic. No model is called, and the same transcripts (and the same registry list, see covered-cli) give the same set and the same candidate ids.
The Swampify skill (a later issue) runs import, then assess, then has the user's agent read a few example sessions per top candidate, merge duplicates, and offer three to five. assess only has to put the right things near the top. Telling a chore apart from a conversational reply is the agent's job.
Inputs
The same scope inputs as import, so the skill passes one scope to both: since, repos, all, exclude, worktreeGlobs, projectsDir, codexDir.
- At onboarding the workspace is new and the user's sessions are spread across many directories, so the skill passes
allwith anyexclude. Nothing is written into those directories. - The default window is 30 days, which is Claude Code's usual retention. The run records the window and scope it actually used (
window,scope).
How it mines
Reuse the importer's code end to end. A second parser would drift the next time a harness adds a line type.
- Find and place sessions with the existing discover, parse and place code (
claude_code/,codex/,sessions/place.ts). Subagent transcripts count toward their parent's cost but don't start candidates of their own. - Segment shell commands with
classify/shell.tsand label calls withclassify/label.ts. Drop read-only programs and neutral calls from sequences. Naive splitting of shell lines produced tens of thousands of distinct shapes on a real machine, led by control words and quote fragments. - Drop text the harness injects before clustering prompts: skill-load preambles, pasted-content wrappers, messages between agents, and caveat or system wrappers. Very short go-aheads ("yes", "go ahead", "approve and go") repeat a lot, but they continue an earlier task and don't start one. Treat them as part of the turn before them.
- Cluster four kinds:
prompt-repeat: interactive first lines that repeat across sessions once normalised (lower case; URLs, numbers, issue refs and paths become placeholders; a bounded prefix). An occurrence is the prompt and the turns that answer it.headless-job: the same, for headless sessions (invocation: headless). On most machines a repeated headless prompt is a job the raw LLM already runs on a loop, which makes it the strongest case there is. Ranked in its own list.call-sequence: two to five consecutive, distinct, non-neutral calls repeated across sessions. The contract allows up to eight steps.covered-cli: a program run directly and repeatedly that an extension covers by name (coveredPrograminclassify/coverage.ts). A new user has no extensions installed, so match against registry extension names as well as installed ones. Fetching that list is the method's only network call. Offline,assessfalls back to installed coverage and says so in its output. The v1 contract has no field for this, and adding one would mean a v2.
- Cost each occurrence from the turns it spans: tokens (input, output, cache read, cache write), tool calls, active time, and whether any call failed. Tokens are counted per turn, not per call, so a
call-sequenceorcovered-cliis priced by the turns that made its calls, asswampify.mdsays. - Rank by occurrences × median cost per occurrence, raised by failure rate and by the number of distinct sessions. Interactive and headless are ranked separately and interleaved. Keep at most
SWAMPIFY_LIMITS.candidates. Counts carry true totals, and only the sample lists are capped. - Label each candidate deterministically from its normalised key (the prompt prefix, the steps, or the program).
- Ids come from
swampifyCandidateId(kind, invocation, key), so a re-run keeps them.
Evidence and privacy
- Excerpts are at most five per candidate: prompt first lines for prompt-led kinds, redacted call targets for call-led kinds. Each goes through
redact.tsbefore it is capped at the contract's length. - Session records stay prompt-free. Only the candidate set keeps excerpts.
- The README, manifest description and skill say plainly what
assessreads (transcript text, not only call targets) and what it stores (counts, costs, short redacted excerpts). Where the data then goes (local, a datastore,swamp serve) is the user's choice, as for any repo data. - The method's log output names counts only, never excerpt text.
Thin history
A typical user has a few hundred sessions, not thousands. If fewer than three candidates clear the minimum (at least three sessions each), assess still writes the set with what it found. The summary tag says the set is thin, and the skill offers to widen the window or falls back to a typed task. An empty set is a valid result, not an error.
Out of scope
- The skill, and the agent's reading of transcripts (it goes in a swamp workflow that dispatches to a subagent on a cheaper model).
compareand the comparison.swamp startand the core panel.- OpenCode and other harnesses.
- Replay.
Done when
assesswrites a candidate set thatreadSwampifyCandidateSetaccepts, with its tags, on the existing fixtures and on new fixtures that contain repeats of each kind.- A golden test pins the ranked output for the fixtures. Re-running on the same input gives byte-identical content apart from
generatedAt, and the same ids. - Unit tests cover injected-text filtering, go-ahead folding, prompt normalisation, sequence extraction, and ranking that keeps interactive and headless separate.
- A property test shows that no excerpt survives without passing through redaction, and that every bound holds on generated transcripts.
- On a real machine with 30 days of history, a run finishes in seconds and its top interactive candidates include the user's known repeated chores (checked by the implementer locally; no transcript content goes in the PR).
- The README and manifest description split the privacy promise as described above.
Shipped
Click a lifecycle step above to view its details.
system commented 11/10/2026, 10:25:59 PM
Classified automatically when this issue was filed.
- Source: Extensions
If you feel this classification is incorrect, add a ripple to tell us so.
Sign in to post a ripple.