Repository navigation
Clear main and second mates into a fresh conversation past a set size - #40
Merged
Merged
Conversation
A supervisor whose conversation reaches 150,000 tokens is cleared at its next idle moment, and always before 200,000; config/supervisor-clear changes both or turns the policy off. A clear is a fresh conversation after the supervisor writes down its open work, never a compaction. - bin/fm-supervisor-clear.sh owns the policy. The watcher runs one pass every two minutes; restarts and the /clear helper run detached. - Second mates over the soft size and idle, or any at the hard size, are restarted through fm-secondmate-restart.sh --keep-profile --reason context, which keeps the recorded harness, model and effort and asks a mate mid-turn to finish its step first. - Main is told through a check wake to save its open work and run `fm-supervisor-clear.sh saved`. A helper outside main's conversation then types /clear into main's recorded pane only when the pane is idle, the input box is proven empty, nothing changed between two reads, and no model call just ran. Session start records main's pane and confirms the clear. At the hard size, anything that blocks the clear becomes one line for the captain. - Every ask, save, clear, skip and restart is logged in state/supervisor-clear/clear.log.
This was referenced Nov 27, 2026
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 this is
Main and every second mate get a fresh conversation once theirs grows large: from 150,000 tokens they are cleared at their next idle moment, and always before 200,000. A clear starts a new conversation after the supervisor writes down its open work (the /stow skill's open-record persistence only). It never compacts.
config/supervisor-clearcan change both sizes or turn the policy off.How it works
bin/fm-supervisor-clear.showns the policy. Its header holds the rules, anddocs/configuration.md"Supervisor clear policy" holds the settings./clearhelper run in their own process group, so nothing new is added to supervision.bin/fm-context-size.sh, unchanged, which already reads remote mates.fm-secondmate-restart.sh --keep-profile --reason context.--keep-profilekeeps the harness, model and effort in the mate's record, for both local and remote mates. Without the flag, the update-time restart works as before.check: supervisor-clear:notification. It asks main to save its open work, runfm-supervisor-clear.sh saved, and end the turn./clearinto main's pane. Session start records that pane (backend and target from main's own environment), so it is never guessed. The helper types only when all of these hold:/clear.state/supervisor-clear/clear.log(who, size before, when).Tests
tests/fm-supervisor-clear.test.shhas 14 cases. It uses real size reads from a sample session log, the real busy-state record, and a stand-in pane./clear, and the clear is confirmed and logged.tests/fm-secondmate-restart.test.sh: a restart with--keep-profile --reason contextkeeps the recorded model and effort, both locally and over the remote hop. Today's code rejects the flag, so this case fails there.fm-session-start.test.sh,bin/fm-lint.sh, andbin/fm-doc-audience-check.sh.Notes
bin/fm-test-run.sh --check-coveragealready reports a shard over its 900,000 ms target on main without this change. Fixing that needs CI timing hints, which this PR does not change./clearinto a real Claude pane. The guard uses the busy and input-box checks the away-mode injection already relies on. A live check can be added if wanted.