Answer architecture round 1: 1 🔴, 6 🟡; escalate in an unrouted chunk's first cycle, hold the limit and marker in routing.py, count escalations per starting rung, decline counting the limit from the current rung
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
from model_routing.ladder import climbed, highest, LADDER, position, Rung
|
||||
from loop_claude.routing import ESCALATION_MARKER, escalation_rungs
|
||||
from model_routing.ladder import highest, LADDER, Rung
|
||||
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
||||
from loop_claude.routing import item_rung
|
||||
from markdown_text import quoted
|
||||
from model_routing.route import Route
|
||||
|
||||
# How many rungs above the one its item picks the worker may escalate a task without the human's yes: docs/decisions.md → `routing: a worker hands a task one rung up`.
|
||||
ESCALATION_CAP = 2
|
||||
|
||||
|
||||
def either(names: tuple[str, ...]) -> str:
|
||||
"""The names as `a, b or c`."""
|
||||
return f"{', '.join(names[:-1])} or {names[-1]}"
|
||||
@@ -21,7 +17,8 @@ ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could
|
||||
|
||||
|
||||
def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str:
|
||||
routed = f"{routed_by(route, anchor)}\n\n" if route.item else ""
|
||||
# A chunk no item routed gets no route paragraph, but may still escalate.
|
||||
routed = f"{routed_by(route, anchor)}\n\n" if route.item else "".join(f"{text.lstrip()}\n\n" for text in [escalation(route, anchor)] if text)
|
||||
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.\n\n{routed}The chunk's todo.md items, or else the task above, set its scope. The goals below choose between ways to deliver that scope, and never widen it.\n\nFrom README.md:\n{premises}"
|
||||
|
||||
|
||||
@@ -41,15 +38,15 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str:
|
||||
|
||||
|
||||
def escalation(route: Route, anchor: Rung | None) -> str:
|
||||
"""The rungs an escalation trigger lets the worker hand a task to: from one above its own up to ESCALATION_CAP above the rung its item picks; empty off the ladder or on its top rung."""
|
||||
if anchor is None or route.rung not in LADDER or route.rung == LADDER[-1]:
|
||||
"""The rungs routing.escalation_rungs opens to the worker, and how to mark an escalated subagent's prompt; empty off the ladder or on its top rung."""
|
||||
if anchor is None or route.rung not in LADDER[:-1]:
|
||||
return ""
|
||||
cap = position(climbed(item_rung(anchor, route), ESCALATION_CAP))
|
||||
rungs = [f"`{rung.agent_args()}`" for rung in LADDER[position(route.rung) + 1:cap + 1]]
|
||||
marked = f" Open the subagent's prompt with `{ESCALATION_MARKER} <n>:`, n the trigger's number."
|
||||
rungs = [f"`{rung.agent_args()}`" for rung in escalation_rungs(anchor, route)]
|
||||
if not rungs:
|
||||
return " An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees."
|
||||
return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees.{marked}"
|
||||
further = f", and on each further trigger one rung higher, up to {rungs[-1]}" if len(rungs) > 1 else ""
|
||||
return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first."
|
||||
return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first.{marked}"
|
||||
|
||||
|
||||
def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str:
|
||||
|
||||
Reference in New Issue
Block a user