Answer principles round 1: 0 🔴, 9 🟡 (0 misread); name the 200k window's compaction point, read a compaction summary as Claude Code's, remove item 231, refresh items 234, 235, 52 and 102, file item 237

This commit is contained in:
2026-10-27 00:32:10 +01:00
parent f2e239d111
commit 14736e8e6e
11 changed files with 48 additions and 63 deletions
+3 -3
View File
@@ -5,7 +5,7 @@ import typing
from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanTalked, HumanTyped, Interrupting, Judging, QUOTED_ANSWERS_PER_CYCLE, Ruled, State, TalkChosen, Talking, transition, TypedAnswer, WorkerRan, Working
from loop_claude.routing import after_ruling, judge_rung
from transcript_archive.write import archive
from loop_claude.cycle.worker import AUTO_COMPACT_WINDOW, COMPACT_ABOVE, run_worker, worker_args
from loop_claude.cycle.worker import AUTO_COMPACT_WINDOW, COMPACT_WINDOW, run_worker, worker_args
from claude_code.session import delete_session, Session, session_open, transcript_file
from loop_claude.effects import Effects
from failure import Failure
@@ -116,8 +116,8 @@ def work(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, step_up: Ste
def worker_environment(cycle: Cycle) -> dict[str, str]:
"""The rungs the worker's claude is handed, which rule-hook holds its review launches to, and the context size above which it compacts."""
return {**worker_rungs.environment(cycle.project, cycle.route), AUTO_COMPACT_WINDOW: str(COMPACT_ABOVE)}
"""The rungs the worker's claude is handed, which rule-hook holds its review launches to, and the auto-compact window of its context."""
return {**worker_rungs.environment(cycle.project, cycle.route), AUTO_COMPACT_WINDOW: str(COMPACT_WINDOW)}
def worker_start(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, step_up: StepUp | None) -> list[str]:
+2 -2
View File
@@ -12,9 +12,9 @@ from claude_code.session import Session
PRINTED_TOOL_INPUT = 160
# Seconds between reads of the machine's memory while too little of it is available to start a worker.
MEMORY_POLL = 60
# The context size, in tokens, above which the worker's claude compacts, handed to it in this variable: docs/decisions.md → `loop-claude: the worker's claude compacts its context above 200k tokens`.
# The auto-compact window, in tokens, handed to the worker's claude in this variable. Claude Code compacts before the window fills, at about 170k: docs/decisions.md → `loop-claude: the worker's claude compacts its context before it fills a 200k window`.
AUTO_COMPACT_WINDOW = "CLAUDE_CODE_AUTO_COMPACT_WINDOW"
COMPACT_ABOVE = 200_000
COMPACT_WINDOW = 200_000
def run_worker(root: str, args: list[str], env: dict[str, str], effects: Effects) -> Failure | Limited | None:
+4 -3
View File
@@ -47,9 +47,10 @@ time. The layout, and when a copy is replaced, are in bin/transcript_archive/__i
Before each worker starts, loop-claude waits until at least a quarter of the machine's memory is available
(bin/machine_load/memory.py).
Each worker's claude, and the session /talk opens, compacts its context once it passes 200k tokens,
handed as CLAUDE_CODE_AUTO_COMPACT_WINDOW (bin/loop_claude/cycle/worker.py), so a long chunk
re-reads less each turn; ~/.claude/CLAUDE.md → "Compact instructions" says what the summary keeps.
Each worker's claude, and the session /talk opens, runs with a 200k auto-compact window, handed as
CLAUDE_CODE_AUTO_COMPACT_WINDOW (bin/loop_claude/cycle/worker.py), so it compacts its context at
about 170k tokens and a long chunk re-reads less each turn.
~/.claude/CLAUDE.md → "Compact instructions" says what the summary keeps.
Every claude loop-claude starts runs the project's model, saved per <key> in
~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker,
+1 -1
View File
@@ -252,7 +252,7 @@ class Cycles(unittest.TestCase):
self.assertIn("- A preflight fact.", fresh)
self.assertNotIn("- A preflight fact.", resumed)
def test_a_worker_is_handed_the_projects_rung_its_own_and_its_reviews_e_plus_i_in_its_environment(self):
def test_a_worker_is_handed_the_projects_rung_its_own_its_reviews_e_plus_i_and_its_compaction_window_in_its_environment(self):
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")])
cycle = dataclasses.replace(self.cycle(fake), project=Rung("claude-opus-5-5", "medium"), route=Route(Rung("claude-haiku-5-5", "max"), 163, 1, 5))
self.assertEqual(run.run_cycle(cycle).verdict, Finished("working"))