Repository navigation
feat(agent): keep a file's reads out of compaction (roadmap B5, S4) - #314
Merged
Merged
Conversation
The last increment of B5, and the one its acceptance had to be rewritten for: `/drop <path>` cannot remove a run's tool results, because those live inside Run and the TUI refuses commands while a run is active. The decision therefore moves to where it can be made — before the run. `Agent.KeptPaths` names files whose tool reads must survive compaction. `compactRunMessages` walks the rounds it would summarize and keeps any round whose `tool_calls` arguments mention a kept path, verbatim, after the compaction marker and before the recent tail. A run whose every round is kept is left alone and costs no summary call. The list travels with the session (`session.Session.KeptPaths`), so `--resume` keeps the rule. Commands: `/keep <path>`, `/keep` (list), `/unkeep <path>`, all refused while a run is active — the run's compaction reads that list. Verified: go test ./... -count=1 and -race, 16 packages ok; go vet and gofmt clean; both load-bearing paths mutation-checked — disabling the kept-round check fails "the kept read was summarized away", and dropping the persist line fails "the session kept []". Refs #306, #168
The palette grew by two entries with S4's commands, and at 80x24 the "Commands:" heading now scrolls off the list before the list scrolls. The scenario's first wait was on that heading, so it timed out with the palette correctly open. It waits on "Show help" — the first entry — instead: that is what "the palette is open" means, and it does not depend on the list fitting one screen. Run locally through tuiprobe: 13 steps, exit 0. Refs #314
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
agent:KeptPaths+KeepPath/UnkeepPath/keepsPath;compactRunMessageskeeps any round whosetool_callsarguments name a kept path verbatim (after the marker, before the tail), summarizes therest, and does nothing at all when every round is kept.
session:Session.KeptPaths, written bypersistSessionand restored byadoptSession, so a resumekeeps the rule.
/keep <path>,/keep(list),/unkeep <path>, all refused while a run is active; paletteentries and
/helplines; goldens regenerated.CODEBASE.md(the three functions), roadmap B5 → Delivered — [agent] Give context management turn-level control: pin, unpin, drop #306 (17 delivered, 1 inprogress, 21 not started, total 40), test count 1285 → 1291.
Why
S4's acceptance was rewritten when S2 landed, because its original sentence — "
/drop <path>removes thetool results that read that path" — assumed a command channel that does not exist: a run's messages are
local to
Run, and the TUI refuses commands (which would mutate the slice the run appends to) while itruns. The rule therefore moves to where it can be made safely: before the run, persisted with the
session.
Kept rounds are re-inserted after the compaction marker rather than in place. That is the same
approximation the pinned-group rule makes for history compression: a summary is already a lossy stand-in,
and keeping the text at all matters more than its exact position in the stand-in.
Verification
go test ./... -count=1and-race: 16 packagesok;go vetandgofmt -lclean.TestCompactRunMessagesKeepsPathsTheUserKeptfails withthe kept read was summarized away;TestKeepPathSurvivesTheSessionFilefails withthe session kept [].agent(list cleaning/dedupe, a kept read surviving while an unkept one is summarized,an all-kept run costing no call) and 3 in
tui(the three command forms, persist + resume, the runguard).
git log --format='%h %G? %s'→G.Honest scope
a.goalso matchesdata/a.go. Fora path a person types at the prompt that is a convenience, not a correctness guarantee; a directory
prefix would be the alternative and was not chosen.
unless it is still the same session.
"keep" means, and the tool layer's own truncation is what bounds a single result.
Follow-ups
Refs #306, #168