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 reply that is only a word of the request gets the block to write, with the path in it (#544)

aswathas17eb623c5130
diff --git a/runner/aider_driver.py b/runner/aider_driver.py
index a347116c..98b927d4 100644
--- a/runner/aider_driver.py
+++ b/runner/aider_driver.py
@@ -559,9 +559,49 @@ def _files_asked_for(prompt: str, root: str = ".", names: "set | None | bool" =
return found
-def _file_nudge(names: list) -> str:
+def _example_block(name: str) -> str:
+ """The block the model is asked to write, with the path in it.
+
+ The path is the part the driver knows; the contents are the request's, and the slot for them
+ is left to it. The block is aider's own wire format (editblock_coder.py:
+ find_original_update_blocks), so a model that copies it writes the file."""
+ return (f"{name}\n```\n<<<<<<< SEARCH\n=======\n"
+ "<the contents the request asks for>\n>>>>>>> REPLACE\n```")
+
+
+def _repeats_a_word_of(reply: str, prompt: str) -> str:
+ """The word a reply is nothing but, when the request holds that word too.
+
+ "" for a reply that says more than one word, or a word the request does not contain. What has
+ no letter or digit in it is not a word: gpt-5.4-mini answered a fresh file request with two NUL
+ characters, a blank line and "DONE" (0.35.13's release check, 2026-10-21). A code fence and its
+ language tag are formatting: it answered "```text DONE ```" twice in one reply as well (2026-10-22)."""
+ words = [w.strip(".,:;!?\"'()[]`") for w in re.sub(r"`{3,}[^\s`]*", " ", reply or "").split()]
+ words = [w for w in words if any(ch.isalnum() for ch in w)]
+ if not words or len({w.lower() for w in words}) != 1:
+ return ""
+ found = re.search(rf"(?<!\w){re.escape(words[0])}(?!\w)", prompt or "", re.I)
+ return words[0] if found else ""
+
+
+def _file_nudge(names: list, word: str = "") -> str:
+ """The nudge for a file the request asked for and the turn has not written.
+
+ `word` is the word the reply was, when it was nothing but a word of the request ("DONE" to
+ "…then reply DONE."). gpt-5.4-mini answers a file request that way once a few exact-reply
+ turns have primed it (#513): "DONE", no file, 5 of 6, and "DONE" again after the nudge. A
+ paragraph asking for a block does not lift it out of the pattern, so the nudge then carries
+ the block to write, with the path in it: a block to copy beats a paragraph to obey."""
listed = ", ".join(f"`{n}`" for n in names)
one = len(names) == 1
+ if word:
+ blocks = "\n\n".join(_example_block(n) for n in names)
+ return (f"'{word}' is not the answer: the request asks for {listed}, and "
+ f"{'it is' if one else 'they are'} not written yet. Write "
+ f"{'it' if one else 'them'} now, in this reply, with a SEARCH/REPLACE block "
+ f"{'like this one' if one else 'each, like these'}:\n\n{blocks}\n\nA new file does "
+ "not need to be added to the chat first. The reply the request asks for comes "
+ "after the file.")
return (f"The request asks for {listed}, and {'it is' if one else 'they are'} not written yet. "
f"Write {'it' if one else 'them'} now in this reply with a SEARCH/REPLACE block "
"each: the path, an empty SEARCH section and the contents in the REPLACE section. A "
@@ -694,7 +734,9 @@ 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.
+ skill with `cat` and answered "DONE" made no file. A reply that is nothing but a word of the
+ request gets the block to write in the nudge, with the path in it (#513): gpt-5.4-mini, primed
+ by a few exact-reply turns, answers that way and writes no file whatever the nudge says.
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
@@ -741,19 +783,20 @@ def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
acted = bool(edited) or (gate is not None and len(gate.calls) > calls_before)
if not coder.reflected_message and not nudged:
reply = (coder.partial_response_content or "").rstrip()
+ words = strip_edit_blocks(reply)
# Asked for and still not at its path: a turn that wrote a.txt of "a.txt and b.txt" is
# nudged for b.txt alone, and a command that wrote the file left it there. A reply that
# asks the person something is waiting for them, and an empty one is a failed call
# (a provider error, a timeout) that a second call would only repeat.
missing = [n for n in wanted if n not in reported
and not os.path.exists(os.path.join(root, n))]
- if missing and reply and not _ASKS_PERSON.search(strip_edit_blocks(reply)):
+ if missing and reply and not _ASKS_PERSON.search(words):
nudged = True
- coder.reflected_message = _file_nudge(missing)
+ coder.reflected_message = _file_nudge(missing, _repeats_a_word_of(words, prompt))
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):
+ elif acted and reply and wants_reply and not words:
nudged = True
coder.reflected_message = REPLY_NUDGE
if not coder.reflected_message:
diff --git a/runner/tests/test_aider_driver.py b/runner/tests/test_aider_driver.py
index a956b924..ea512f7b 100644
--- a/runner/tests/test_aider_driver.py
+++ b/runner/tests/test_aider_driver.py
@@ -522,7 +522,8 @@ def test_a_file_request_answered_with_a_word_and_no_edit_is_nudged_once():
self.gate.calls.append({"command": "cat SKILL.md", "approved": True})
return iter(())
ask = "Create a file named hello-aider.txt containing exactly the word HELLO, then reply DONE."
- nudge = aider_driver._file_nudge(["hello-aider.txt"])
+ nudge = aider_driver._file_nudge(["hello-aider.txt"], "DONE") # the reply was the word
+ plain = aider_driver._file_nudge(["hello-aider.txt"]) # the reply was more than that
assert "`hello-aider.txt`" in nudge and "SEARCH/REPLACE" in nudge
assert "does not need to be added to the chat" in nudge
assert "`a.txt`, `b.txt`" in aider_driver._file_nudge(["a.txt", "b.txt"])
@@ -538,7 +539,7 @@ def test_a_file_request_answered_with_a_word_and_no_edit_is_nudged_once():
c = Coder(["DONE", "DONE"]); aider_driver._run_turn(c, ask, gate)
assert c.sent == [ask, nudge] # once, not twice
c = Coder(["I'll create it now.", "I'll do it."]); aider_driver._run_turn(c, ask, gate)
- assert c.sent == [ask, nudge] # one nudge, the specific one
+ assert c.sent == [ask, plain] # one nudge, the specific one
c = Coder(["Paris."]); aider_driver._run_turn(c, "What is the capital of France?", gate)
assert c.sent == ["What is the capital of France?"] # a question is not nudged
c = Coder(["It would hold HELLO."]); aider_driver._run_turn(c, "what would a hello.txt contain?", gate)
@@ -564,7 +565,7 @@ def test_a_file_request_answered_with_a_word_and_no_edit_is_nudged_once():
# two files asked for and one written: nudged for the other alone, once
two = "Create a.txt and b.txt, then reply DONE."
c = Coder(["DONE", "DONE"], edits=["edit:a.txt", "edit:b.txt"]); aider_driver._run_turn(c, two, gate)
- assert c.sent == [two, aider_driver._file_nudge(["b.txt"])]
+ assert c.sent == [two, aider_driver._file_nudge(["b.txt"], "DONE")]
assert "`a.txt`" not in c.sent[1] and "it is not written yet" in c.sent[1]
pathlib.Path(root, "hello-aider.txt").write_text("HELLO\n")
c = Coder(["DONE"]); aider_driver._run_turn(c, ask, gate)
@@ -603,6 +604,55 @@ 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_file_request_answered_with_the_requested_word_gets_the_block_to_write():
+ """#513: a file request that comes after a few exact-reply turns ("Reply with exactly:
+ M1-gpt-5.4-mini", M2, M3) is answered by gpt-5.4-mini with the requested word and no file:
+ "Create a file named hello-aider.txt containing exactly the word HELLO, then reply DONE."
+ answered "DONE", 5 of 6, and answered "DONE" again after the nudge; a fresh session wrote the
+ file 3 of 3. The nudge a paragraph asks for does not lift the model out of the pattern, so a
+ reply that is nothing but a word of the request gets the block to write, with the path in it.
+ A reply that says more than that word keeps the plain nudge."""
+ root = tempfile.mkdtemp()
+
+ class Coder:
+ def __init__(self, replies):
+ self.replies = list(replies); 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): pass
+ def send_message(self, m):
+ self.sent.append(m); self.partial_response_content = self.replies.pop(0)
+ return iter(())
+ gate = aider_driver._Gate([])
+ ask = "Create a file named hello-aider.txt containing exactly the word HELLO, then reply DONE."
+
+ c = Coder(["DONE", "DONE"]); aider_driver._run_turn(c, ask, gate)
+ assert len(c.sent) == 2
+ nudge = c.sent[1]
+ assert "'DONE' is not the answer" in nudge # the word is not the answer
+ assert "<<<<<<< SEARCH" in nudge and "hello-aider.txt\n```" in nudge # the block, path in it
+ assert "does not need to be added to the chat" in nudge
+ c = Coder(["I'll create it now.", "I'll do it."]); aider_driver._run_turn(c, ask, gate)
+ assert "<<<<<<< SEARCH" not in c.sent[1] # more than a word: the plain nudge
+ c = Coder(["Sure", "Sure"]); aider_driver._run_turn(c, ask, gate)
+ assert "<<<<<<< SEARCH" not in c.sent[1] # a word that is not the request's
+
+ repeats = aider_driver._repeats_a_word_of
+ assert repeats("DONE", ask) == "DONE" and repeats("done.", ask) == "done"
+ assert repeats("DONE\n\nDONE", ask) == "DONE" # the same word twice
+ assert repeats("I wrote DONE", ask) == "" and repeats("Sure", ask) == ""
+ assert repeats("", ask) == "" and repeats("DONE", "") == ""
+ # The release check of 0.35.13 (2026-10-21): a fresh session answered the same request with two
+ # NUL characters, a blank line and "DONE" (8 output tokens, no file). What has no letter or
+ # digit in it is not a word, so that reply is the word too.
+ assert repeats("\u0000\u0000\n\nDONE", ask) == "DONE"
+ assert repeats("he", "Write the file") == "" # a word of the request, not part of one
+ # rc.1 of 0.35.14 (2026-10-22): 2 of 6 primed runs answered with the word in a fenced block, twice.
+ # A fence and its language tag are formatting, not words.
+ assert repeats("```text\nDONE\n```\n\n```text\nDONE\n```", ask) == "DONE"
+
+
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