nisse-review: a review refused for an open point posts once the point is answered
On #166 the reviewer called post_review with two points unanswered, was refused, answered them, then only skipped already-answered points until the 40-turn cap: the review went out as partial, its summary lost. A refused ending call is now held, and the driver ends the run with it as soon as the last point is settled (a new due hook in nisse-core's driver; nisse-dev doesn't use it). A held call that is wrong for another reason by then (sign_off over drafted comments) is left to the model. With nothing open, reply and skip say which tool ends the run. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
This commit is contained in:
1 parent
be81adc185
commit
26ef125d1e
5 files changed
+221
-22
No files matched your search
@@ -108,6 +108,7 @@ class Driver:
|
||||
on_turn: Callable[[str], None] | None = None,
|
||||
screen: Callable[[ToolCall], Screening] | None = None,
|
||||
max_turns: int | None = None,
|
||||
due: Callable[[], tuple[str, dict[str, Any], str] | None] | None = None,
|
||||
) -> RunOutcome:
|
||||
"""``waiting``: the control tools that end the run, for the
|
||||
scheduler to act on. ``handlers`` answer those that don't (e.g.
|
||||
@@ -115,7 +116,10 @@ class Driver:
|
||||
``checks`` vet a waiting tool's arguments: a problem is the call's
|
||||
failed result and the run goes on, so the model puts it right.
|
||||
``screen`` judges each execution call before it reaches the tool VM
|
||||
(P4)."""
|
||||
(P4). ``due``, asked after each handled call, names a waiting call
|
||||
the harness held back that may now go ahead (tool, arguments, what
|
||||
to tell the model): the run ends with it, as if the model had made
|
||||
it again."""
|
||||
handlers = handlers or {}
|
||||
checks = checks or {}
|
||||
model = model or self._model # the work item's pinned driver (L9)
|
||||
@@ -193,6 +197,23 @@ class Driver:
|
||||
result, ok = handlers[call.tool](dict(call.arguments))
|
||||
except VMUnreachable as exc:
|
||||
return self._unreachable(transcript, calls, index, str(exc))
|
||||
held = due() if ok and due is not None else None
|
||||
if held is not None:
|
||||
tool, arguments, said = held
|
||||
transcript.append(
|
||||
ToolResult(
|
||||
call_id=call.call_id,
|
||||
result=f"{result}\n\n[harness] {said}; your turn "
|
||||
"has ended",
|
||||
success=True,
|
||||
)
|
||||
)
|
||||
skip_calls(
|
||||
transcript,
|
||||
calls[index + 1 :],
|
||||
"not run: the turn had ended",
|
||||
)
|
||||
return RunOutcome("wait", tool, arguments)
|
||||
elif call.tool not in offered or workspace is None:
|
||||
result, ok = (
|
||||
f"no such tool: {call.tool}; the tools are "
|
||||
|
||||
@@ -81,3 +81,72 @@ def test_a_tool_not_named_waiting_doesnt_end_the_run(tmp_path: Path) -> None:
|
||||
)
|
||||
assert ran.tool == "post_review"
|
||||
assert results(log)[0].startswith("no such tool: ask_human")
|
||||
|
||||
|
||||
NOTE = tool("note", "Note something.", text="The note.")
|
||||
|
||||
|
||||
def test_a_held_call_goes_ahead_once_due_says_so(tmp_path: Path) -> None:
|
||||
# post_review is refused while a point is open and held by the agent;
|
||||
# the handled call that settles the point ends the run with it.
|
||||
open_points = ["P1"]
|
||||
held: dict[str, Any] = {}
|
||||
|
||||
def refuse(args: dict[str, Any]) -> str | None:
|
||||
if open_points:
|
||||
held["call"] = ("post_review", args)
|
||||
return "answer P1 first"
|
||||
return None
|
||||
|
||||
def settle(args: dict[str, Any]) -> tuple[str, bool]:
|
||||
open_points.clear()
|
||||
return "answered P1", True
|
||||
|
||||
def due() -> tuple[str, dict[str, Any], str] | None:
|
||||
if "call" in held and not open_points:
|
||||
tool_, args = held.pop("call")
|
||||
return tool_, args, "your held post_review went ahead"
|
||||
return None
|
||||
|
||||
model = Scripted(
|
||||
[call("post_review", body="the summary")],
|
||||
[call("note", text="P1"), call("read_file", path="a.py")],
|
||||
# never reached: the run ended on the note
|
||||
[call("note", text="again")],
|
||||
)
|
||||
log = transcript(tmp_path)
|
||||
reader = Reader()
|
||||
ran = Driver(model, "m").run(
|
||||
log,
|
||||
system="s",
|
||||
tools=[READ, POST, NOTE],
|
||||
waiting={"post_review"},
|
||||
workspace=reader,
|
||||
handlers={"note": settle},
|
||||
checks={"post_review": refuse},
|
||||
due=due,
|
||||
)
|
||||
assert (ran.kind, ran.tool, ran.arguments) == (
|
||||
"wait",
|
||||
"post_review",
|
||||
{"body": "the summary"},
|
||||
)
|
||||
assert results(log) == [
|
||||
"answer P1 first",
|
||||
"answered P1\n\n[harness] your held post_review went ahead; your turn has ended",
|
||||
"not run: the turn had ended",
|
||||
]
|
||||
assert reader.calls == [] # the read after it never ran
|
||||
|
||||
|
||||
def test_without_due_a_settled_point_leaves_the_run_going(tmp_path: Path) -> None:
|
||||
model = Scripted([call("note", text="x")], [call("post_review", body="b")])
|
||||
ran = Driver(model, "m").run(
|
||||
transcript(tmp_path),
|
||||
system="s",
|
||||
tools=[POST, NOTE],
|
||||
waiting={"post_review"},
|
||||
workspace=None,
|
||||
handlers={"note": lambda args: ("noted", True)},
|
||||
)
|
||||
assert (ran.tool, ran.arguments) == ("post_review", {"body": "b"})
|
||||
Reference in new issue
Block a user