Trivial output handling around a sisi command is not legwork; the fallback names the action; live check attributes real-data changes by marker. done: live fixes / next: final runs

This commit is contained in:
swaits committed 2026-11-23 14:35:46 -07:00
1 parent 424993fa9e
commit 14ac958824
4 files changed
+52 -11

No files matched your search

+2 -2
View File
@@ -74,8 +74,8 @@ def fallback_text(info, cwd, own_model):
if worker:
return "\n".join([head,
"Next for the same kind of work (%s, difficulty %s): %s (%s)." % (kind, diff, worker, mech),
"Fall back now with the same brief. Do not ask the person, and do not report this to them: "
"which worker is out is internal.", cancel])
"Fall back now with the same brief: start it on that worker now and give the person its result. "
"Do not ask the person, and do not report this to them: which worker is out is internal.", cancel])
due = workers.earliest_due()
return "\n".join([head,
"No other worker is usable now%s." % ((" (earliest due: %s at %s)" % (due[0], fmt_time(due[1]))) if due else ""),
+11 -3
View File
@@ -115,11 +115,17 @@ def _segments(cmd):
return segs
# what may stand around a `sisi` command without making the line legwork: trivial output handling
_TRIVIAL = {"echo", "printf", "true", "false", "head", "tail", "grep", "wc", "sort", "uniq", "cut", "tr"}
def runs_sisi(cmd):
"""True when every command in the shell line is an invocation of `sisi` itself."""
"""True when the shell line is `sisi` itself: at least one `sisi` invocation, and nothing else on the line but
trivial output handling (`; echo "exit=$?"`, `| head -20`). `sisi x && cat src/*` is not."""
segs = _segments(cmd or "")
if not segs:
return False
found = False
for seg in segs:
toks = [t for t in seg if not re.match(r"^[A-Za-z_]\w*=", t)]
if not toks:
@@ -127,9 +133,11 @@ def runs_sisi(cmd):
first = toks[0]
if re.match(r"^python[\d.]*$", os.path.basename(first)) and len(toks) > 1:
first = toks[1]
if os.path.basename(first) != "sisi":
if os.path.basename(first) == "sisi":
found = True
elif os.path.basename(toks[0]) not in _TRIVIAL:
return False
return True
return found
def classify(host, tool, inp, cmd):
+11
View File
@@ -128,6 +128,17 @@ class BudgetTests(MeterBase):
self.read_n(6)
self.assertTrue(self.pre("Bash", {"command": "sisi status && cat src/*"})[0])
self.assertTrue(self.pre("Bash", {"command": "echo sisi"})[0])
self.assertTrue(self.pre("Bash", {"command": "sisi status; cat src/a.py"})[0])
self.assertTrue(self.pre("Bash", {"command": "sisi status | xargs cat"})[0])
def test_trivial_output_handling_around_a_sisi_command_does_not_make_it_legwork(self):
"""Found by the live check: `sisi unit direct "..."; echo "exit=$?"` was refused as a counted command, so the
agent could not use either way on."""
self.prompt()
self.read_n(6)
for cmd in ('sisi unit direct "a specific reason of 40 lines"; echo "exit=$?"', "sisi route --kind test --difficulty 1 --explain 2>&1; echo \"exit=$?\"",
"sisi delegate brief | head -20", "sisi status && echo done"):
self.assertFalse(self.pre("Bash", {"command": cmd})[0], cmd)
def test_the_turn_resets_at_each_prompt(self):
self.prompt()
+28 -6
View File
@@ -35,10 +35,11 @@ MAIN_MODEL = "haiku" # the host's least expensive model, the
WORKERS = (("sonnet", 3), ("opus", 15)) # fixture workers (names the host's subagent tool accepts) and a price each
RESET = "2036-12-01T00:00:00Z" # the reset time the fake provider's error message names
QUOTA_TEXT = ("API error 429 [request_id=req_live]: Subscription quota exhausted. Your usage window resets at " + RESET)
PROMPT2 = ("This project is in the current directory. Have a worker do one small task: list the python "
"files in src/, one per line. Ask `sisi route --kind research --difficulty 1` who the cheapest suitable worker is, write the brief "
"(`sisi delegate brief` prints the template; save it as brief.md), and run it with "
"`sisi delegate --kind research --difficulty 1 --brief brief.md`. The listing must come from a worker, not from your own commands. The list is what I want back: reply with it.")
PROMPT2 = ("This project is in the current directory. Have a worker do one small task: list the python files in src/, "
"one per line. `sisi route --kind research --difficulty 1` tells you which worker to use, `sisi delegate brief` prints "
"the brief template (save the brief as brief.md), and `sisi delegate --kind research --difficulty 1 --brief brief.md` "
"runs a brief on a command-line worker. The listing must come from a worker, not from your own commands. "
"The list is what I want back: reply with it.")
PROMPT = ("This project is in the current directory. Find and fix the bug (a test in tests/ fails), then tell me "
"what each file in src/ does, one line per file.")
@@ -103,6 +104,23 @@ def fixture_fallback(data, tmpbin):
os.chmod(exe, 0o755)
def changed_by_this_run(before, after, root, markers):
"""Files under the real data folder that changed between two snapshots AND mention something only this run
could have written (its temporary folder's name). Other sisi sessions on the machine change the real data
too; a change that never names this run is theirs, and is listed so nobody has to trust that."""
b = {r[0]: r for r in before}
changed = [r[0] for r in after if b.get(r[0]) != r]
mine, others = [], []
for rel in changed:
try:
with open(os.path.join(root, rel), "rb") as f:
text = f.read(5 * 1024 * 1024).decode("utf-8", "replace")
except OSError:
continue
(mine if any(m in text for m in markers) else others).append(rel)
return mine, others
def real_data_dir():
env = dict(os.environ)
for k in ("SISI_DATA", "SISI_HOME"):
@@ -321,8 +339,12 @@ def main(argv):
failures += f
report += r
worlds.append(w)
if snapshot(real) != before_real:
failures.append("(d) files under the real sisi data folder (%s) changed" % real)
after_real = snapshot(real)
mine, others = changed_by_this_run(before_real, after_real, real, [os.path.basename(w["tmp"]) for w in worlds if w])
if mine:
failures.append("(d) files under the real sisi data folder (%s) changed and name this run: %s" % (real, mine))
report.append("(d) real sisi data folder: %d file(s) changed during the run, none naming this run%s"
% (len(others), (" (other sessions' activity: %s)" % ", ".join(others[:4])) if others else ""))
print("\n\n".join(report))
if failures:
print("\nLIVE CHECK FAILED:\n " + "\n ".join(failures))