Answer prose round 1: 0 🔴, 2 🟡 (0 misread); reword the timer's docstrings, comments and help, rename the no-compaction test
This commit is contained in:
@@ -21,7 +21,7 @@ ANSWER_QUESTION = "answer the question above"
|
|||||||
# TALK, what the human types at loop-claude's terminal to open claude for the question, and ASK_ANSWER were picked on 2026-10-17 by a bench of three readers seated as the README's audience, as ~/.claude/CLAUDE.md → "Working loop" → "Bench a syntax with the people who write it." has it.
|
# TALK, what the human types at loop-claude's terminal to open claude for the question, and ASK_ANSWER were picked on 2026-10-17 by a bench of three readers seated as the README's audience, as ~/.claude/CLAUDE.md → "Working loop" → "Bench a syntax with the people who write it." has it.
|
||||||
TALK = "/talk"
|
TALK = "/talk"
|
||||||
ASK_ANSWER = f"Answer ({TALK} opens claude, Enter stops the loop): "
|
ASK_ANSWER = f"Answer ({TALK} opens claude, Enter stops the loop): "
|
||||||
# While the human hasn't answered, the worker's session is compacted CACHE_MARGIN seconds before its hour-long prompt cache expires: compacting reads the context from the cache, while resuming after it expired writes the whole context again. Below COMPACT_FLOOR tokens of context, that write costs less than compacting. A five-minute cache expires within the margin, so it is left as it is. lilleman chose this on 2026-11-11.
|
# While the human hasn't answered, the worker's session is compacted CACHE_MARGIN seconds before its hour-long prompt cache expires: compacting reads the context from the cache, while resuming after it expired writes the whole context again. Below COMPACT_FLOOR tokens of context, that write costs less than compacting. A five-minute cache expires within the margin, so a session that last wrote one isn't compacted. lilleman chose this on 2026-11-11.
|
||||||
HOUR_CACHE = 3600
|
HOUR_CACHE = 3600
|
||||||
CACHE_MARGIN = 600
|
CACHE_MARGIN = 600
|
||||||
COMPACT_FLOOR = 60_000
|
COMPACT_FLOOR = 60_000
|
||||||
@@ -75,7 +75,7 @@ def answered(answer_here: bool, session: WorkerSession, effects: Effects) -> str
|
|||||||
|
|
||||||
|
|
||||||
def waited_answer(session: WorkerSession, effects: Effects) -> str | Stop:
|
def waited_answer(session: WorkerSession, effects: Effects) -> str | Stop:
|
||||||
"""typed_answer, compacting the worker's session where no answer has come shortly before its prompt cache expires. The claude TALK opens compacts an idle session itself."""
|
"""typed_answer, compacting the worker's session where no answer has come by CACHE_MARGIN seconds before its prompt cache expires. /talk needs no compaction: the claude it opens compacts an idle session itself."""
|
||||||
entries = read_transcript(session.transcript_path)
|
entries = read_transcript(session.transcript_path)
|
||||||
now = effects.now()
|
now = effects.now()
|
||||||
delay = None if isinstance(entries, Failure) else compaction_delay(entries, now)
|
delay = None if isinstance(entries, Failure) else compaction_delay(entries, now)
|
||||||
|
|||||||
@@ -58,16 +58,16 @@ there:
|
|||||||
- /talk: opens the worker's claude session with `claude --resume` on the terminal, to read the diff
|
- /talk: opens the worker's claude session with `claude --resume` on the terminal, to read the diff
|
||||||
or discuss first. Once that claude exits, the judge rules on what was typed there.
|
or discuss first. Once that claude exits, the judge rules on what was typed there.
|
||||||
- Enter alone: stops the loop.
|
- Enter alone: stops the loop.
|
||||||
Where no answer has come 10 minutes before the worker's hour-long prompt cache expires, and its
|
|
||||||
context holds at least 60k tokens, loop-claude compacts the worker's session with
|
|
||||||
`claude -p /compact` and keeps waiting, so the resume doesn't write the whole context again.
|
|
||||||
A release ready to cut opens that claude session on the terminal at once, since only the human may
|
A release ready to cut opens that claude session on the terminal at once, since only the human may
|
||||||
cut it. While claude is open, Ctrl-C reaches it alone, and the loop goes on. Where the project's
|
cut it. While claude is open, Ctrl-C reaches it alone, and the loop goes on. Where the project's
|
||||||
config sets notifier, loop-claude also sends the human each question, naming its tmux window as
|
config sets notifier, loop-claude also sends the human each question, naming its tmux window as
|
||||||
<session>:<window>, each release ready to cut and each stop as a DM, as bin/notify sends it. Four
|
<session>:<window>, each release ready to cut and each stop as a DM, as bin/notify sends it. Four
|
||||||
stops are left out: Ctrl-C, printing this help, the loop-claude that started the windows once it
|
stops are left out: Ctrl-C, printing this help, the loop-claude that started the windows once it
|
||||||
attaches or prints how to, and a loop whose chunk finished once it started the next chunks. A DM
|
attaches or prints how to, and a loop whose chunk finished once it started the next chunks. A DM
|
||||||
that fails is said on stderr, and the loop goes on.
|
that fails is said on stderr, and the loop goes on. Where no answer has come 10 minutes before the
|
||||||
|
worker's hour-long prompt cache expires, and the worker's context holds at least 60k tokens,
|
||||||
|
loop-claude compacts the worker's session with `claude -p /compact` and keeps waiting, so the resume
|
||||||
|
doesn't write the whole context again.
|
||||||
|
|
||||||
As a chunk starts, before it is routed, loop-claude runs bin/chunk-preflight --worktree, adding
|
As a chunk starts, before it is routed, loop-claude runs bin/chunk-preflight --worktree, adding
|
||||||
--item <ID> in a window named for an item, and quotes what it prints in the first prompt
|
--item <ID> in a window named for an item, and quotes what it prints in the first prompt
|
||||||
|
|||||||
@@ -838,7 +838,7 @@ class Interrupts(unittest.TestCase):
|
|||||||
handle.write(json.dumps(said) + "\n")
|
handle.write(json.dumps(said) + "\n")
|
||||||
|
|
||||||
def fired(self, fake, answer):
|
def fired(self, fake, answer):
|
||||||
"""An input the human types answer at, after every timer started has fired."""
|
"""An input that first fires every timer started, then returns answer as the line the human typed."""
|
||||||
def typed(prompt):
|
def typed(prompt):
|
||||||
for _, action in fake.timers:
|
for _, action in fake.timers:
|
||||||
action()
|
action()
|
||||||
@@ -895,7 +895,7 @@ class Interrupts(unittest.TestCase):
|
|||||||
self.assertEqual([seam for seam, _ in fake.calls if seam in ("memory", "sleep", "stream_claude")], ["stream_claude"])
|
self.assertEqual([seam for seam, _ in fake.calls if seam in ("memory", "sleep", "stream_claude")], ["stream_claude"])
|
||||||
self.assertNotIn("waiting to start the worker", said)
|
self.assertNotIn("waiting to start the worker", said)
|
||||||
|
|
||||||
def test_an_answer_before_the_timer_fires_stops_it_and_compacts_nothing(self):
|
def test_an_answer_before_the_timer_fires_stops_it_and_doesnt_compact_anything(self):
|
||||||
self.worked(minutes_ago=10)
|
self.worked(minutes_ago=10)
|
||||||
fake = FakeEffects(inputs=["Use B."])
|
fake = FakeEffects(inputs=["Use B."])
|
||||||
self.assertEqual(self.put(fake)[0], "Use B.")
|
self.assertEqual(self.put(fake)[0], "Use B.")
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ def run_python(args: list[str], cwd: str, timeout: float) -> subprocess.Complete
|
|||||||
def start_timer(delay: float, action: typing.Callable[[], None]) -> typing.Callable[[], None]:
|
def start_timer(delay: float, action: typing.Callable[[], None]) -> typing.Callable[[], None]:
|
||||||
"""Runs action on a thread of its own once delay seconds have passed, and returns what stops the timer: it cancels an action not yet started, and waits for one that has started to end."""
|
"""Runs action on a thread of its own once delay seconds have passed, and returns what stops the timer: it cancels an action not yet started, and waits for one that has started to end."""
|
||||||
timer = threading.Timer(delay, action)
|
timer = threading.Timer(delay, action)
|
||||||
# A loop that exits while it waits doesn't wait for the action.
|
# A timer still running doesn't keep the process alive once the loop exits.
|
||||||
timer.daemon = True
|
timer.daemon = True
|
||||||
timer.start()
|
timer.start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user