From f32a26cfdc78c6641a809a9e2568c747cc3c4b02 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 26 Sep 2026 13:22:44 +0200 Subject: [PATCH 1/5] Plan the judge reading the human's typed turns --- todo.md | 1 + 1 file changed, 1 insertion(+) diff --git a/todo.md b/todo.md index 09376d94..9664c4b6 100644 --- a/todo.md +++ b/todo.md @@ -4,6 +4,7 @@ Bar the reload item, ordered by how many seats of the 2026-09-25 scoring panel (`docs/decisions.md`) named the place; each is one chunk. +- Render the human's typed turns into the transcript the judge reads, today `render` keeps only assistant entries, so a question the human answered at an interrupt is asked again and the loop exits 2 when they leave that second session untouched. - Carry the reload state of `bin/loop-claude` as one JSON argument, and exit naming the reload when it arrives without a task, today a new argument shifts the task out and an older running loop reloads into `usage` and exit 1. - Name `end_session` for what it does, today it deletes the session's transcript files. - Define looping reviewer and round cap under `CLAUDE.md` → "Vocabulary", today inline at `agents/review-protocol.md`. -- 2.52.0 From b20a7e349b3e4aa34f50d7a58e66722fc7b9e259 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 26 Sep 2026 13:22:44 +0200 Subject: [PATCH 2/5] Expect render to carry the human's typed turns --- bin/test_loop_claude.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index c8276ae3..d222fbf2 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -66,13 +66,16 @@ class ReadPremises(unittest.TestCase): class Render(unittest.TestCase): - def test_joins_assistant_text_and_tool_calls_and_skips_the_rest(self): + def test_joins_assistant_text_and_tool_calls_and_human_turns_and_skips_the_rest(self): said = loop.render([ human("do it"), assistant({"type": "text", "text": "Starting."}, {"type": "tool_use", "name": "Bash", "input": {"command": "ls"}}), assistant({"type": "text", "text": " "}), + human([{"type": "tool_result", "content": "not typed"}]), + human("/exit"), + human([{"type": "text", "text": "yes, "}, {"type": "text", "text": "merge it"}]), ]) - self.assertEqual(said, 'Starting.\n\n[tool Bash] {"command": "ls"}') + self.assertEqual(said, '[human] do it\n\nStarting.\n\n[tool Bash] {"command": "ls"}\n\n[human] yes, merge it') class HumanTurns(unittest.TestCase): -- 2.52.0 From 2341c504506fe1b2090e55a6b4a70e4d9a342e73 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 26 Sep 2026 13:23:01 +0200 Subject: [PATCH 3/5] Render the human's typed turns for the judge, so an answered question is not asked again --- bin/loop-claude | 9 ++++++--- todo.md | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index ca1fa494..1c30b686 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -59,8 +59,8 @@ JUDGE_RULES = ( "rule the rejected one out - and the choice materially changes the deliverable\n" "ask=false otherwise. A sensible preference is not a derivation. Bookkeeping the agent settled " "silently - what to document, wording, where a note goes - is not on its own a reason to " - "interrupt. The human may have replied inside the transcript: judge only what is still open, " - "never a question they already answered there.\n" + "interrupt. The human may have replied inside the transcript, on a [human] line: judge only what " + "is still open, never a question they already answered there.\n" "The question must be one the agent itself raised. Never construct a question from facts the agent " "stated. When ask=true, quote the agent's own wording where it already framed the question.\n" "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " @@ -171,6 +171,9 @@ def render(entries): for entry in entries: if entry.get("type") == "assistant": lines += [line for part in entry.get("message", {}).get("content", []) if (line := said(part))] + elif typed(entry): + content = entry["message"]["content"] + lines.append("[human] " + (content if isinstance(content, str) else "".join(part["text"] for part in content))) return "\n\n".join(lines) @@ -286,7 +289,7 @@ def judge_prompt(task, premises, transcript): f"From README.md:\n{premises}\n\n" f"The task an agent was given:\n{task}\n\n" # The tail, where an ask or a finish lands; the session's transcript grows cycle over cycle. - f"What the agent then did and said, latest last:\n{transcript[-40000:]}\n\n" + f"What the agent did and said, and what the human typed on [human] lines, latest last:\n{transcript[-40000:]}\n\n" f"{JUDGE_RULES}" ) diff --git a/todo.md b/todo.md index 9664c4b6..09376d94 100644 --- a/todo.md +++ b/todo.md @@ -4,7 +4,6 @@ Bar the reload item, ordered by how many seats of the 2026-09-25 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- Render the human's typed turns into the transcript the judge reads, today `render` keeps only assistant entries, so a question the human answered at an interrupt is asked again and the loop exits 2 when they leave that second session untouched. - Carry the reload state of `bin/loop-claude` as one JSON argument, and exit naming the reload when it arrives without a task, today a new argument shifts the task out and an older running loop reloads into `usage` and exit 1. - Name `end_session` for what it does, today it deletes the session's transcript files. - Define looping reviewer and round cap under `CLAUDE.md` → "Vocabulary", today inline at `agents/review-protocol.md`. -- 2.52.0 From bd7a41a57ba3fda78bd02d592fa9fdc1f0ebc9ae Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 26 Sep 2026 13:28:17 +0200 Subject: [PATCH 4/5] Expect the loop's own prompts, promptSource sdk, to be no human turn --- bin/test_loop_claude.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index d222fbf2..2224c7f7 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -74,6 +74,7 @@ class Render(unittest.TestCase): human([{"type": "tool_result", "content": "not typed"}]), human("/exit"), human([{"type": "text", "text": "yes, "}, {"type": "text", "text": "merge it"}]), + {**human("Continue the task; the previous run stopped before it was finished."), "promptSource": "sdk"}, ]) self.assertEqual(said, '[human] do it\n\nStarting.\n\n[tool Bash] {"command": "ls"}\n\n[human] yes, merge it') @@ -86,6 +87,7 @@ class HumanTurns(unittest.TestCase): human([{"type": "tool_result", "content": "not typed"}]), human("/model"), {**human("peer message"), "isMeta": True}, + {**human("the loop's own prompt"), "promptSource": "sdk"}, human([{"type": "text", "text": "[Request interrupted by user]"}]), human([]), assistant({"type": "text", "text": "said"}), -- 2.52.0 From 64a752c76be16e5a47555903f0af2d88ab0dc6ae Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 26 Sep 2026 13:28:18 +0200 Subject: [PATCH 5/5] Exclude the loop's own prompts from human turns by promptSource sdk --- bin/loop-claude | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index 1c30b686..e088fbf9 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -26,7 +26,8 @@ boundary, once the new file answers --help. Claude Code internals this rests on, observed on 2.1.282: - The transcript is ~/.claude/projects/*/.jsonl, one JSON object per line. A / folder and .superseded-*/ and .orphaned-*.jsonl siblings belong to the same session. -- Claude Code writes "user" entries of its own into the transcript; typed() tells a human's from them. +- Claude Code writes "user" entries of its own into the transcript, and a `claude -p` prompt lands as one + with promptSource "sdk"; typed() tells a human's from them. - An "assistant" entry, in the transcript and in --output-format stream-json, carries message.content parts of type "text" (text) and "tool_use" (name, input); stream-json ends with a "result" event. - `claude -p --output-format json --json-schema` returns the verdict under "structured_output". @@ -173,13 +174,13 @@ def render(entries): lines += [line for part in entry.get("message", {}).get("content", []) if (line := said(part))] elif typed(entry): content = entry["message"]["content"] - lines.append("[human] " + (content if isinstance(content, str) else "".join(part["text"] for part in content))) + lines.append("[human] " + (content if isinstance(content, str) else "".join(part.get("text", "") for part in content))) return "\n\n".join(lines) def typed(entry): - """A human turn: a "user" entry, not isMeta, whose message.content is a string not starting with "<" ( and its kind) or one or more text parts, none starting with "[Request interrupted".""" - if entry.get("type") != "user" or entry.get("isMeta"): + """A human turn: a "user" entry, not isMeta, not promptSource "sdk" (the loop's own prompts), whose message.content is a string not starting with "<" ( and its kind) or one or more text parts, none starting with "[Request interrupted".""" + if entry.get("type") != "user" or entry.get("isMeta") or entry.get("promptSource") == "sdk": return False content = entry.get("message", {}).get("content") if isinstance(content, str): -- 2.52.0