Answer an interrupt on loop-claude's terminal and resume the worker headless with the answer

This commit is contained in:
2026-10-17 23:04:28 +02:00
parent eddc5bec95
commit 831b9c63b6
17 changed files with 304 additions and 117 deletions
+22 -3
View File
@@ -124,9 +124,28 @@ def rungs_held(route: Route, anchor: Rung | None) -> str:
def answered(question: str, answer: str, route: Route, anchor: Rung | None, stepped: bool) -> str:
"""stepped is whether the answer's ruling stepped the worker up, so the prompt names its new rung, as resumed does."""
on = f" Your request for a higher rung went through: loop-claude runs you on {route.rung}.{rungs_held(route, anchor)} A further request for a higher rung steps you up no more in this cycle." if stepped else ""
return f"Your question: {question}\n\n{QUOTE_SOURCES} answers it:\n\n{answer}\n\nContinue the task.{on}"
"""stepped is whether the answer's ruling stepped the worker up."""
return f"Your question: {question}\n\n{QUOTE_SOURCES} answers it:\n\n{answer}\n\nContinue the task.{stepped_to(route, anchor, stepped)}"
def typed(question: str, answer: str, route: Route, anchor: Rung | None, stepped: bool) -> str:
"""Resumes the worker with the human's answer to an interrupt. answer is one line, as the terminal reads it, so typed_answer finds where it ends."""
return f"Your question: {question}\n\n{TYPED_HERE}\n\n{answer}\n\nContinue the task.{stepped_to(route, anchor, stepped)}"
# Precedes the answer in typed's prompt.
TYPED_HERE = "The human answers it at loop-claude's terminal:"
def typed_answer(prompt: str) -> str | None:
"""The answer typed put in prompt, so the judge reads it as the human's; None for any other prompt. The last TYPED_HERE is typed's: the one-line answer cannot hold it, and only the sentences on a stepped rung follow."""
_, here, after = prompt.rpartition(f"\n\n{TYPED_HERE}\n\n")
return after.split("\n", 1)[0] if here and prompt.startswith("Your question: ") else None
def stepped_to(route: Route, anchor: Rung | None, stepped: bool) -> str:
"""Where the ruling that brought the answer stepped the worker up, names its new rung, as resumed does."""
return f" Your request for a higher rung went through: loop-claude runs you on {route.rung}.{rungs_held(route, anchor)} A further request for a higher rung steps you up no more in this cycle." if stepped else ""
def past_the_cap(question: str, answer: str, cap: int) -> str: