Name the driver of a cycle in the text its worker, judge and human read

This commit is contained in:
2026-11-18 20:34:40 +01:00
parent b827986ec8
commit c4d06c55b5
15 changed files with 213 additions and 169 deletions
+7 -7
View File
@@ -13,14 +13,14 @@ from agent_cycle.direct_message import tell
from agent_cycle import tmux
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 the entry point'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"
ASK_ANSWER = f"Answer ({TALK} opens claude, Enter stops the loop): "
@dataclasses.dataclass(frozen=True)
class WorkerSession:
"""The worker's claude session, which /talk opens on loop-claude's terminal."""
"""The worker's claude session, which /talk opens on the entry point's terminal."""
root: str
id: uuid.UUID
rung: Rung
@@ -37,8 +37,8 @@ class Talked:
"""The human typed in the worker's claude session."""
def interrupt(question: str, answer_here: bool, session: WorkerSession, window: tmux.Window, effects: Effects) -> str | Talked | Stop:
"""Prints question for the human, in window, and returns their answer. While it waits, the window's name ends in tmux.WAITS, and the bell it rings shows in tmux's status bar. The answer: where answer_here, the first line typed at loop-claude's terminal, stripped, or Talked once they typed in the worker's claude session, which TALK opens; else Talked once they typed in that session, which opens at once on the terminal. A Stop where loop-claude is off a terminal, or they type no answer, or the input ends."""
def interrupt(question: str, answer_here: bool, session: WorkerSession, window: tmux.Window, driver: str, effects: Effects) -> str | Talked | Stop:
"""Prints question for the human, in window, and returns their answer. While it waits, the window's name ends in tmux.WAITS, and the bell it rings shows in tmux's status bar. The answer: where answer_here, the first line typed at the terminal of driver, the entry point, stripped, or Talked once they typed in the worker's claude session, which TALK opens; else Talked once they typed in that session, which opens at once on the terminal. A Stop where it is off a terminal, or they type no answer, or the input ends."""
# The bell ends the question's line, so it rings once the question can be read.
say(f"\n{question}{tmux.BELL}", effects)
on_terminal = effects.on_terminal()
@@ -47,8 +47,8 @@ def interrupt(question: str, answer_here: bool, session: WorkerSession, window:
effects.discard_typed()
tmux.mark(window, True, effects.tmux)
# After the discard, so an answer typed while the DM sends counts; before the terminal check, so a loop that cannot ask still tells the human what it would have asked.
tell(f"loop-claude in {session.root} asks, in the tmux window {window.target}:\n\n{question}", effects)
answer = needs_terminal(ANSWER_QUESTION, on_terminal) or answered(answer_here, session, effects)
tell(f"{driver} in {session.root} asks, in the tmux window {window.target}:\n\n{question}", effects)
answer = needs_terminal(ANSWER_QUESTION, on_terminal, driver) or answered(answer_here, session, effects)
# A loop that stops unanswered leaves the mark on its window.
if not isinstance(answer, Stop):
tmux.mark(window, False, effects.tmux)
@@ -64,7 +64,7 @@ def answered(answer_here: bool, session: WorkerSession, effects: Effects) -> str
def typed_answer(effects: Effects) -> str | Stop:
"""The line typed at loop-claude's terminal, stripped. A Stop where they type no answer, or the input ends."""
"""The line typed at the entry point's terminal, stripped. A Stop where they type no answer, or the input ends."""
try:
text = effects.input(ASK_ANSWER).strip()
except EOFError: