Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

aider: a file-writing turn answers in words: a nudge when words were asked for, else a sentence from its edits (#519)

github-actions[bot]28cac79a2dca
diff --git a/runner/aider_driver.py b/runner/aider_driver.py
index a437bc3e..3f2f6108 100644
--- a/runner/aider_driver.py
+++ b/runner/aider_driver.py
@@ -426,6 +426,13 @@ def _workspace_names(root: str) -> "set | None":
a walk blind to dot-folders and node_modules, which a request does not mean. None when neither
can say: then a bare name counts as present, since no nudge is the turn as it was and a wrong
one makes a stray file."""
+ paths = _workspace_paths(root)
+ return None if paths is None else paths | {p.rsplit("/", 1)[-1] for p in paths}
+
+
+def _workspace_paths(root: str) -> "set | None":
+ """The workspace's files by path, as _workspace_names reads them; None when neither git nor a
+ bounded walk can say."""
try:
out = subprocess.run(["git", "-c", "safe.directory=*", "-C", root, "ls-files", "-z",
"--cached", "--others", "--exclude-standard"],
@@ -438,7 +445,24 @@ def _workspace_names(root: str) -> "set | None":
paths += [os.path.relpath(os.path.join(d, f), root) for f in files]
if len(paths) > _WALK_CAP:
return None
- return set(paths) | {p.rsplit("/", 1)[-1] for p in paths}
+ return set(paths)
+
+
+def _edits_sentence(edited: list, before: "set | None") -> str:
+ """What a turn changed, said from the edits themselves, for a turn whose model wrote only edit
+ blocks: its answer is empty once they are cards. Measured 2026-10-19 on "Create a file named
+ hello.txt containing hi, then say done.": the reply was the edit block alone in 6 of 24 runs
+ (gpt-5.4 4 of 6), and 11 of 24 on 0.35.2. A file absent from the workspace before the turn was
+ created; one that was there was edited. With no listing to tell them apart, every file is
+ "edited", which a written file also is. Names up to two files, then counts; nothing else."""
+ created = sorted(p for p in edited if before is not None and p not in before)
+ changed = sorted(p for p in edited if p not in created)
+
+ def files(ps: list) -> str:
+ return " and ".join(ps) if len(ps) <= 2 else f"{len(ps)} files"
+ if created and changed:
+ return f"Created {files(created)}{', and' if len(created) == 2 else ' and'} edited {files(changed)}."
+ return f"Created {files(created)}." if created else f"Edited {files(changed)}."
def _exists_in(root: str, name: str, names: "set | None") -> bool:
@@ -488,6 +512,31 @@ def _file_nudge(names: list) -> str:
"asks for.")
+# A request that asks for words back once the work is done: "Create a file named hello.txt
+# containing hi, then say done." gpt-5.4-mini answered it with the edit block and nothing else (21
+# output tokens, its chat history shows no other words; the runner read-back on 0.35.3's driver,
+# 2026-10-18): the file was written and the person's answer was the driver's "The task ended
+# without a written answer" sentence. aider gives the model one response per turn, and the block
+# was that response, the mirror of #379's "DONE" with no file. Keyed on the request, like the file
+# nudge: the verb opens a clause, so "the answer is in notes.md" asks for nothing. ENGLISH ONLY: the
+# openers are English words, so a request in another language never gets this nudge. Such a turn
+# still ends with words, the sentence _edits_sentence builds from its edits, which is also the answer
+# whenever this nudge is not sent or was already spent on another one this turn.
+_ASKS_REPLY = re.compile(
+ r"(?:^|[.;:!?]\s+|\n\s*|,\s*|\b(?:and|then|please|now|also|just|finally|afterwards)\s+)"
+ r"(?:say|reply|respond|answer|confirm|report|tell me|let me know)\b", re.I)
+REPLY_NUDGE = ("What this turn wrote and ran is done, so do not write or run it again. Now give the "
+ "reply the request asks for, in words, with no SEARCH/REPLACE block and no command.")
+
+
+def _asks_for_reply(prompt: str) -> bool:
+ """Whether this turn's request asks for words back (earlier turns put ahead of it are not it)."""
+ text = prompt or ""
+ if text.startswith("<conversation_so_far>\n"):
+ text = text.rpartition("</conversation_so_far>\n\n")[2]
+ return bool(_ASKS_REPLY.search(text))
+
+
NEW_FILE_NOTE = ("If the request asks for a new file, it needs no adding to the chat: write it with "
"a SEARCH/REPLACE block that has its path, an empty SEARCH section and the contents "
"in REPLACE, then give the reply the request asks for. A question about a file is "
@@ -571,7 +620,12 @@ def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
files and asks for the edit blocks, since the general nudge's "otherwise give your final
answer" is the way out the model already took. A reply that asks the person
something is not nudged. A command counts only by what it left on disk: a turn that read a
- skill with `cat` and answered "DONE" made no file. One nudge per turn either way."""
+ skill with `cat` and answered "DONE" made no file.
+
+ And the same one nudge the other way round: a request that asks for words back ("then say
+ done") answered by a pass that edited or ran something and said nothing besides. Without it the
+ answer is the driver's "ended without a written answer" sentence over a task that is done. One
+ nudge per turn in every case."""
coder.io.user_input(prompt)
coder.init_before_message()
message = prompt
@@ -580,6 +634,7 @@ def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
nudged = False
root = getattr(coder, "root", None) or "."
wanted = _files_asked_for(prompt, root)
+ wants_reply = _asks_for_reply(prompt)
while message:
coder.reflected_message = None
calls_before = len(gate.calls) if gate is not None else 0
@@ -605,6 +660,9 @@ def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
elif not acted and _announces_without_acting(reply):
nudged = True
coder.reflected_message = NUDGE
+ elif acted and reply and wants_reply and not strip_edit_blocks(reply):
+ nudged = True
+ coder.reflected_message = REPLY_NUDGE
if not coder.reflected_message:
break
if reflections >= coder.max_reflections:
@@ -818,6 +876,7 @@ def main() -> int:
_run_shell_commands_reporting(coder, gate, reflect=bool(job.get("reflect_shell_output", True)))
_emit("init", {"model": coder.main_model.name, "edit_format": coder.edit_format})
+ before = _workspace_paths(cwd) # what was there, so the turn's edits say created or edited
try:
_run_turn(coder, job["prompt"], gate)
except Exception as exc: # noqa: BLE001 — the turn's failure is the product here, not a crash
@@ -841,11 +900,14 @@ def main() -> int:
# further turn when that printed nothing. Measured on the hosted service (an officecli
# that was not installed ran seven times and the task ended with no text and no file;
# gpt-5.4 ended after one edit block). Said as what happened, not as an answer the model
- # gave. The same two sentences on the hosted service.
- final = ("The task ended without a written answer after running commands. The commands "
- "and their output are above." if gate.calls else
- "The task ended without a written answer after editing files. What it did is "
- "shown above.")
+ # gave: the files it changed, by name, or the commands it ran. The same on the hosted service.
+ edited = sorted(coder.aider_edited_files or [])
+ if edited:
+ final = _edits_sentence(edited, before) + (
+ " The commands and their output are above." if gate.calls else "")
+ else:
+ final = ("The task ended without a written answer after running commands. The commands "
+ "and their output are above.")
_emit("result", {
"final": final,
"ok": not failed,
diff --git a/runner/tests/test_aider_driver.py b/runner/tests/test_aider_driver.py
index b6ac5411..9dad46b0 100644
--- a/runner/tests/test_aider_driver.py
+++ b/runner/tests/test_aider_driver.py
@@ -330,7 +330,33 @@ def test_a_turn_that_ended_on_a_command_says_so_rather_than_saying_nothing():
src = pathlib.Path(__file__).resolve().parents[1].joinpath("aider_driver.py").read_text()
assert "if not final.strip() and not failed and (gate.calls or coder.aider_edited_files):" in src
assert "The task ended without a written answer after running commands." in src
- assert "The task ended without a written answer after editing files." in src
+ # an edit-only turn says which files it changed (below), not that it wrote no answer
+ assert "The task ended without a written answer after editing files." not in src
+ assert "final = _edits_sentence(edited, before)" in src
+
+
+def test_a_turn_that_only_wrote_edit_blocks_says_which_files_it_changed(tmp_path):
+ """The model's whole reply was the edit block, without the "done" it was asked for (6 of 24 on
+ "Create a file named hello.txt containing hi, then say done.", 2026-10-19), and the answer read
+ "The task ended without a written answer". It now names what the turn changed, from the edits
+ themselves: created when the file was not in the workspace before the turn, edited when it
+ was. Nothing is said that the edits do not show."""
+ S = aider_driver._edits_sentence
+ assert S(["hello.txt"], set()) == "Created hello.txt."
+ assert S(["hello.txt"], {"hello.txt"}) == "Edited hello.txt."
+ assert S(["a.txt", "b.txt"], set()) == "Created a.txt and b.txt."
+ assert S(["hello.txt", "src/x.py", "y.md"], {"src/x.py", "y.md"}) == "Created hello.txt and edited src/x.py and y.md."
+ assert S(["a", "b", "c", "d"], {"c", "d"}) == "Created a and b, and edited c and d."
+ assert S(["a", "b", "c"], {"a", "b", "c"}) == "Edited 3 files."
+ assert S(["n1", "n2", "n3", "old"], {"old"}) == "Created 3 files and edited old."
+ assert S(["hello.txt"], None) == "Edited hello.txt." # no listing: every written file is edited
+ # created means absent before the turn, by path: a hello.txt elsewhere does not make it edited
+ (tmp_path / "src").mkdir()
+ (tmp_path / "src" / "hello.txt").write_text("x")
+ before = aider_driver._workspace_paths(str(tmp_path))
+ assert before == {"src/hello.txt"}
+ assert S(["hello.txt"], before) == "Created hello.txt."
+ assert "hello.txt" in aider_driver._workspace_names(str(tmp_path)) # the nudge's bare names stay
def test_a_reply_that_announces_work_and_does_none_is_nudged_once():
@@ -550,6 +576,57 @@ def test_a_file_request_answered_with_a_word_and_no_edit_is_nudged_once():
assert c.sent == [ask, "lint: fix this", nudge]
+def test_a_request_for_words_back_answered_by_an_edit_alone_is_nudged_once():
+ """The runner read-back on 0.35.3's driver (2026-10-18): "Create a file named hello.txt
+ containing hi, then say done." gpt-5.4-mini answered with the edit block and no other word (its
+ chat history), so hello.txt was written and the answer was "The task ended without a written
+ answer after editing files." A request that asks for words back gets one nudge for them, and
+ the nudged reply is the answer; a reply with words, a request that asks for none, a failed call
+ and a second wordless reply get none."""
+ root = tempfile.mkdtemp()
+
+ class Coder:
+ def __init__(self, replies, edits=None, gate=None):
+ self.replies = list(replies); self.edits = list(edits or []); self.gate = gate
+ self.reflected_message = None; self.partial_response_content = ""; self.root = root
+ self.aider_edited_files = set(); self.max_reflections = 5
+ self.io = types.SimpleNamespace(user_input=lambda p: None); self.sent = []
+ def init_before_message(self): self.aider_edited_files = set()
+ def send_message(self, m):
+ self.sent.append(m); self.partial_response_content = self.replies.pop(0)
+ step = self.edits.pop(0) if self.edits else None
+ if step == "edit":
+ self.aider_edited_files.add("hello.txt"); pathlib.Path(root, "hello.txt").write_text("hi\n")
+ elif step == "run": # a command that printed nothing: no reflection
+ self.gate.calls.append({"command": "touch hello.txt", "approved": True})
+ return iter(())
+ ask = "Create a file named hello.txt containing hi, then say done."
+ block = "hello.txt\n```text\n<<<<<<< SEARCH\n=======\nhi\n>>>>>>> REPLACE\n```\n" # the reply, verbatim
+ gate = aider_driver._Gate([])
+ c = Coder([block, "done"], edits=["edit"]); logged = []; c.io = types.SimpleNamespace(user_input=logged.append)
+ aider_driver._run_turn(c, ask, gate)
+ assert c.sent == [ask, aider_driver.REPLY_NUDGE] and logged == [ask, aider_driver.REPLY_NUDGE]
+ assert aider_driver.strip_edit_blocks(c.partial_response_content) == "done" # what the result says
+ assert "do not write or run it again" in aider_driver.REPLY_NUDGE
+ c = Coder([block, block], edits=["edit"]); aider_driver._run_turn(c, ask, gate)
+ assert c.sent == [ask, aider_driver.REPLY_NUDGE] # once, not twice
+ c = Coder([block + "\ndone"], edits=["edit"]); aider_driver._run_turn(c, ask, gate)
+ assert c.sent == [ask] # it said the word
+ c = Coder([block], edits=["edit"]); aider_driver._run_turn(c, "Create a file named hello.txt containing hi.", gate)
+ assert len(c.sent) == 1 # no word asked for: the edit is the turn
+ c = Coder([""]); aider_driver._run_turn(c, ask, gate)
+ assert c.sent == [ask] # a failed call is not repeated
+ g = aider_driver._Gate([])
+ c = Coder(["```bash\ntouch hello.txt\n```", "done"], edits=["run"], gate=g); aider_driver._run_turn(c, ask, g)
+ assert c.sent == [ask, aider_driver.REPLY_NUDGE] # a command and no word, the same
+ a = aider_driver._asks_for_reply
+ assert a("Create a.txt and b.txt, then reply DONE.") and a("Reply with exactly: M1-gpt-5.4")
+ assert a("Fix the bug in app.py and tell me what it was") and a("Update notes.md. Confirm when done.")
+ assert not a("Create hello.txt containing hi") and not a("the answer is in notes.md")
+ assert not a("write an essay to essay.md") and not a("Make the report in report.md")
+ assert not a("<conversation_so_far>\nuser: say hi\n</conversation_so_far>\n\nCreate hello.txt")
+
+
def test_a_chat_with_no_files_says_a_new_file_needs_no_adding():
"""aider's "I am not sharing any files that you can edit yet." made gpt-5.4-mini refuse to
create a file, even after a nudge (#379). The no-files message says a new file is written with