Skip to content

Cut per-session context: th prime cap, gated handoff, quiet mail-guard - #772

Merged
brentrager merged 1 commit into
mainfrom
th-context-trim
Oct 6, 2026
Merged

brentrager merged 1 commit into
mainfrom
th-context-trim

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

Sessions start at ~88k tokens. th prime (~9.3k chars; ready list of 1470 pearls cut at 40), the compact/resume handoff hook (96k chars in the smooai main checkout, 36k in smooth main) and mail-guard.sh stop (182 forced extra turns in 10 days, mostly "no mail watcher armed") all add to it.

Changes

  • th prime: ready list capped at 10 (--ready-limit N, $TH_PRIME_READY_LIMIT, 0 hides) + … +N more — run th pearls ready; terse primer that keeps the rules.
  • handoff-context.sh / precompact-checkpoint.sh: shared relevant-pearls.sh. Linked worktree: unchanged. Primary checkout: only pearls this session checkpointed or whose id is in the branch. Max 3 packets × 1500 chars. PreCompact no longer stamps every pearl with the session id.
  • mail-guard.sh: stop blocks only for unread direct mail, once per distinct count per session; an unarmed watcher with no direct mail never blocks. Unarmed reminder = one line of prompt context, once per session (the SessionStart line counts).
  • --wake on th msg watch / th msg unread-count: direct mail + broadcast request/handoff/cancel. Broadcast notes/results stay in the inbox but don't wake the watcher or count toward the nudge. watch-once.sh passes --wake, retrying without it on clap exit 2 (older th).
  • register-agent.sh: one line (412 → 219 chars).
  • clippy fix: FakeTool::new → build in hooks/sidekick.rs tests.

Verification

  • Hook suites: flow-hook 49/49 (new: packet cap, primary-checkout filter, fresh-session PreCompact stamps nothing, linked worktree), mail-guard 32/32 (new: unarmed never blocks, dedupe, wake count, once-per-session nag), watch-once 7/7, attest-push-hint 34, enforce-worktree 21, statusline 17.
  • cargo test: smooth-pearls mail_store 34 ok (new wake-count test); smooth-cli prime_tests + mail:: 34 ok (new cap + parse tests); smooth-daemon hooks::sidekick 6 ok. Clippy on the three crates: no errors.

🤖 Generated with Claude Code

Every session started near 88k tokens, and th prime plus the plugin hooks
re-injected bulk on each resume/compact.

- th prime: cap the ready list at 10 (--ready-limit / TH_PRIME_READY_LIMIT)
  with a "+N more" line; terse primer instead of the command reference.
- handoff-context/precompact: only pearls this session is on. In the primary
  checkout the old --cwd match pulled every pearl checkpointed there (96k
  chars in smooai main); now session-checkpointed or branch-named only, max 3
  packets, each capped.
- mail-guard stop: never block on an unarmed watcher with no direct mail
  (182 forced turns in ten days); direct-mail blocks once per count; the
  unarmed reminder is once-per-session prompt context.
- th msg watch/unread-count --wake: broadcast notes/results no longer wake
  the watcher or count toward the nudge.
- register-agent prints one line; rename FakeTool::new (clippy new_ret_no_self).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 027d870

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smooai/smooth Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brentrager
brentrager merged commit c764f4d into main Oct 6, 2026
8 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