Review fixes: the agent marker counts only at the very start of the first request; quick work is timed from its first request, and a failed check or a backwards clock still sends it to the retro
ci / test (push) Canceled after 0s

This commit is contained in:
swaits committed 2026-11-24 13:41:03 -07:00
1 parent dacfc84594
commit aa6c268f58
4 files changed
+17 -8

No files matched your search

+3 -2
View File
@@ -7,7 +7,7 @@ from . import models, rules, store
# A delegated session says so in the first lines of its first request (the brief), or a host's bracketed line
# at the start of a line says an agent, not the user, sent it.
WORKER = re.compile(r"(?im)^\W*(you are a (worker|subagent|sub-agent|delegate)\b|do this task yourself|do not delegate|\[[^\]\n]{0,200}\bsent this message, not the user\.?\])")
WORKER = re.compile(r"(?im)^\W*(you are a (worker|subagent|sub-agent|delegate)\b|do this task yourself|do not delegate)|\A\s*\[[^\]\n]{0,200}\bsent this message, not the user\.?\]")
DIRECT = ("shell", "read", "edit", "search", "web") # the classes of tool call the meter counts
METER = ("sisi: %d direct tool calls this turn (the limit is %d). Delegate the rest: `sisi models` lists your "
@@ -125,6 +125,7 @@ def prompt(p):
if not s.get("prompts") and WORKER.search(p["prompt"][:2000]):
s["worker"] = True
s["prompts"] = s.get("prompts", 0) + 1
s.get("prompts_since") or s.update(began=time.time()) # the first request of a piece of work
s["prompts_since"] = s.get("prompts_since", 0) + 1
s["direct"], s["extra"], s["blocks"] = 0, 0, 0
return 0
@@ -204,7 +205,7 @@ def gate(p, for_subagent=False):
unsaid = ["%d. %s" % (i, c["text"]) for i, c in enumerate(checks, 1) if not c["verdict"]]
failed = [str(i) for i, c in enumerate(checks, 1) if c["verdict"] == "fail"]
worked = s.get("changed") or store.snapshot(cwd) != s.get("snapshot")
quick = time.time() - (s.get("done") or {}).get("at", 0) < 60 * store.config()["retro_minutes"] and not s.get("delegations_since")
quick = 0 <= time.time() - s.get("began", 0) < 60 * store.config()["retro_minutes"] and not s.get("delegations_since") and not s.get("fails_since")
if checks and not unsaid and not failed and (not worked or quick):
from . import retro
retro.record(s, cwd, {}, sid) # every check passed and nothing changed, or it was quick and alone: the work closes itself
+2 -2
View File
@@ -112,7 +112,7 @@ def record(s, cwd, opt, sid=None):
store.commit("retro recorded", log)
s["snapshot"], s["changed"], s["retro_at"] = store.snapshot(cwd), False, now
for key in ("prompts_since", "direct_since", "delegations_since", "reasons_since", "workers_since", "done", "paused",
"fails_since", "picked", "starts", "retro_demanded"):
"fails_since", "picked", "starts", "retro_demanded", "began"):
s.pop(key, None)
@@ -135,7 +135,7 @@ def done(args, cwd=None):
return 1
with store.session(sid) as s:
if new:
s["done"] = {"goal": opt["goal"][0], "next": opt["next"][0], "at": time.time(),
s["done"] = {"goal": opt["goal"][0], "next": opt["next"][0],
"checks": [{"text": c, "verdict": None, "evidence": ""} for c in opt["check"]]}
elif verdict:
kind, n, why = verdict