
Key takeaways
- Part 4 aligns session lifetime with task lifetime and makes work resumable by another subscription without a transcript
- Use a fresh session for a new task, compaction for a long continuation, and an evidence handoff for a provider switch
- Reusing a session can repeatedly carry old conversations and files into an unrelated request
- A useful handoff contains changed files, verification results, confirmed facts, rejected hypotheses, and one next action
- This part produces
handoff.mdand a transition checklist for Part 5's tool-output budget
Treat session transitions as a state machine
-
Move each session through
fresh → active → compact or handoff → closedfreshreads Part 3's guidance and the current task contractactiveaccumulates only evidence needed for the taskcompactapplies only while the same goal continueshandoffcloses a session or changes its owner
-
A new goal creates a stronger boundary than the convenience of the current chat
- An unrelated review request during a bug fix is a new task
- Analyzing a test failure caused by that fix remains a substep of the same task
-
Anthropic says each turn sends prior conversation, project context and read files, plus the new prompt1
- It recommends
/clearfor a task change and/compactfor a long continuation - This is documented Claude Code behavior; do not assume every product meters identically
- It recommends
Decide between fresh and compact
-
Continue only when all three answers are yes
- The completion condition remains the same
- The allowed paths substantially overlap
- Existing session evidence directly supports the next decision
-
Compaction reduces a conversation; it does not create a task boundary
- Compacting between diagnosis and implementation of one bug can be appropriate
- Start fresh when moving from the finished bug to a new feature
-
Gemini CLI exposes maximum retained turns and a compression threshold2
model.maxSessionTurnsbounds user, model, and tool turns kept in a sessionmodel.chatCompression.contextPercentageThresholdcontrols automatic and manual compression timing- An aggressive value can lose evidence, so validate it against the baseline
Transfer evidence instead of conversation
- Use six provider-neutral Markdown fields
- Goal and completion condition
- Current commit and changed files
- Commands run and results
- Confirmed facts
- Rejected hypotheses with reasons
- One next action or unresolved question
# WEB-41 handoff
- Goal: stabilize tied search-result ordering
- State: commit abc123, modified apps/web/lib/tech/search.ts
- Verified: focused test 14/14 passed, typecheck not run
- Facts: score calculation is stable; final sort lacks an ID tie-breaker
- Rejected: locale collation is not involved because IDs differ before localization
- Next: add the ID tie-breaker test, then run the web typecheck-
Avoid both raw transcripts and narrative summaries
- A transcript forces the next session to re-read failed attempts and outputs
- Long prose blurs confirmed fact, inference, and next action
-
Label inference separately from fact
- Put executed and observed results under
Facts - Put possibilities under
Open questionsso the next agent revalidates them
- Put executed and observed results under
Test whether the handoff actually recovers work
-
A fresh session without the original chat should complete the next verification from the handoff alone
- Three repeated questions suggest missing essential evidence
- Broad re-exploration suggests missing paths or confirmed facts
-
Measure recovery cost, not handoff brevity by itself
- Count turns to the first valid change
- Count duplicate commands and human hints
- Record changes reverted because of a handoff error
-
Frequent handoffs do not always save usage
- A tiny single-file edit can cost less than documenting its state
- A reasoning-heavy design task may first need a stronger decision record
Hand output boundaries to the next part
-
Part 5 caps the evidence inserted into a handoff
- Keep only command, count, and duration for passing tests
- Keep the first error and nearby context for failures
- Pass a file list and relevant hunks instead of an unbounded diff
-
Part 4 is complete when a new provider session resumes without a transcript
- Test one Codex-to-Claude or Claude-to-Codex transition
- Keep Part 1's restriction to official subscription sign-in without API keys
Action plan
- When a new goal appears, update
handoff.mdand open a new session - Within one task, compact when context grows or the response becomes anchored to old hypotheses
- Standardize the protocol only after five transitions reduce duplicate commands and turns to a valid change
Footnotes
-
Anthropic, models, usage, and limits in Claude Code — explains repeated session context and when to use
/clearand/compact↩ -
Google, Gemini CLI configuration — documents maximum session turns and context-compression thresholds ↩


