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: words the automatic file add answered leave the reply, and the added-files message invites no answer (#528)

github-actions[bot]4995106ea67d
diff --git a/runner/aider_driver.py b/runner/aider_driver.py
index 3f2f6108..53ffdab9 100644
--- a/runner/aider_driver.py
+++ b/runner/aider_driver.py
@@ -182,6 +182,24 @@ class _Gate:
# True while the last thing that happened was an error: set by tool_error, cleared by the
# next assistant output. What decides whether the turn failed (see main).
self.error_after_output = False
+ # While _run_turn runs a pass its words are parked here instead of leaving at once: who
+ # they were for is known only after aider's file-mention check has run (see _install).
+ # None outside a pass — then words leave at once, as at any call site off the send path.
+ self.pass_words: "list | None" = None
+ # Set when aider answered the pass itself: check_for_file_mentions added the files the
+ # words asked for and set the reflected message. Reset by _run_turn at each pass.
+ self.answered_by_file_add = False
+
+ def flush_words(self) -> None:
+ """The running pass's parked words, emitted now: a card is about to go out, and the words
+ that narrate it come first, as they always have. A pass that reached a card is already
+ past aider's file-mention check (send_message returns at an answered mention before any
+ edit or command), so these words were for the person."""
+ for w in self.pass_words or []:
+ if w.strip():
+ _emit("text", {"text": w})
+ if self.pass_words:
+ self.pass_words = []
def mcp_calls_in(self, command: str) -> list[tuple[str, str]]:
"""Every ('server', 'tool') an hr-mcp call in this command names, in order.
@@ -242,7 +260,15 @@ def _install(coder, gate: _Gate) -> None:
# An empty content field is the only case aider's decorated display string may be shown for;
# it goes through the banner's own marker rather than being handed over whole (#395).
gate.error_after_output = False
- _emit("text", {"text": strip_edit_blocks(body or _after_answer_banner(str(message)))})
+ text = strip_edit_blocks(body or _after_answer_banner(str(message)))
+ # Parked while a pass runs: whether these words were for the person or for the driver is
+ # known only once aider's file-mention check has answered (or not) at the pass's end. And
+ # an empty text — a response that was edit blocks alone — is no message at all: emitted,
+ # it rendered as an empty reply after the cards (hosted, gpt-5.4, 2026-10-19).
+ if gate.pass_words is not None:
+ gate.pass_words.append(text)
+ elif text:
+ _emit("text", {"text": text})
return orig_assistant(message, pretty)
def tool_error(message="", strip=True):
@@ -253,6 +279,7 @@ def _install(coder, gate: _Gate) -> None:
return orig_error(message, strip)
def tool_warning(message="", strip=True):
+ gate.flush_words()
_emit("warning", {"text": str(message)})
return orig_warning(message, strip)
@@ -267,6 +294,7 @@ def _install(coder, gate: _Gate) -> None:
approved, name, reason = gate.decide(command)
gate.calls.append({"command": command, "tool": name, "approved": approved,
"reason": reason})
+ gate.flush_words()
_emit("shell_decision", {"command": command, "tool": name,
"approved": approved, "reason": reason})
return approved
@@ -281,6 +309,7 @@ def _install(coder, gate: _Gate) -> None:
if question in _FILE_PROMPTS and subject:
path = str(subject) if os.path.isabs(str(subject)) else os.path.join(coder.root, str(subject))
if not is_text_file(path):
+ gate.flush_words()
_emit("warning", {"text": f"{subject} is not a text file and stays out of the chat"})
# aider's prompt tells the model to ask the user for the file and stop; when the
# user says no, a person types what to do instead. Nobody is at that prompt here,
@@ -301,6 +330,25 @@ def _install(coder, gate: _Gate) -> None:
io.tool_warning = tool_warning
io.confirm_ask = confirm_ask
+ # aider answers a file mention ITSELF in driver mode: check_for_file_mentions asks "Add file
+ # to the chat?", --yes-always says yes, and the reflected message it sets ("I added these
+ # files to the chat: …") is the next pass's input. A pass whose words that add answered was
+ # talking to the driver, not the person — measured twice on the hosted twin (gpt-5.4,
+ # 2026-10-19): turn 2 on hello.txt opened the reply with "Please add this file to the chat
+ # first so I can provide an exact edit: - `hello.txt`", a request nobody needed to act on,
+ # then the edit, then an empty message. The WORDING of such a request varies by model
+ # ("Please add this file…", "I need to edit this existing file, which has not been added…"),
+ # so the signal is the mechanism itself — the check returned its added-files message — never
+ # the words.
+ mentions = getattr(coder, "check_for_file_mentions", None)
+ if mentions is not None:
+ def check_for_file_mentions(content):
+ added = mentions(content)
+ if added:
+ gate.answered_by_file_add = True
+ return added
+ coder.check_for_file_mentions = check_for_file_mentions
+
REFLECT_ASK = ("Continue the task with this output. If more commands or edits are needed, propose "
"them now; otherwise write your answer for the user, stating what the output shows.")
@@ -573,6 +621,23 @@ def _new_files_need_no_add(coder) -> None:
coder.gpt_prompts = prompts
+ADDED_FILES = "I added these files to the chat: {fnames}. Continue with the request."
+
+
+def _added_files_without_invitation() -> None:
+ """aider's reflected message after an automatic add ends "Let me know if there are others we
+ should add." — an invitation written for a person at the prompt. Fed back as the next pass's
+ input in the driver's loop, the model ANSWERS it: gpt-6-sol opened the pass after the add with
+ "No other files are needed." and that narration became the turn's answer, in the future tense
+ ("I'll add `there` after `hi`.", rc.1 probe, 2026-10-19). Nobody is at that prompt here, so the
+ message states the add and points back at the request, and invites nothing. It is set on the
+ aider.prompts MODULE, because that is where check_for_file_mentions reads it
+ (base_coder.py:31, 1781) — the coder's gpt_prompts does not carry it — and the turn is its own
+ process, so the patch outlives nothing."""
+ from aider import prompts
+ prompts.added_files = ADDED_FILES
+
+
def _repo_map_after_the_conversation(coder) -> None:
"""THE CONVERSATION STARTS WITH WHAT THE USER SAID, with files in the workspace as without.
aider sends the repo map as a user message, answered for the model with "Ok, I won't try and
@@ -625,7 +690,15 @@ def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
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."""
+ nudge per turn in every case.
+
+ EACH PASS'S WORDS leave when the pass ends, not as they arrive, because who they were for is
+ known only then: a pass whose words were answered by the automatic file add (see _install) was
+ talking to the driver and its words are not part of the reply; every other pass's words are
+ shown as they always were, each its own message, ahead of any cards they narrate (the gate
+ flushes them when a card goes out). The turn's answer is the LAST pass's words (_turn_answer);
+ a mid-turn pass's words stay what they are today, narration beside that pass's cards, and are
+ not joined into the answer. An empty text is never emitted."""
coder.io.user_input(prompt)
coder.init_before_message()
message = prompt
@@ -638,7 +711,18 @@ def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
while message:
coder.reflected_message = None
calls_before = len(gate.calls) if gate is not None else 0
- list(coder.send_message(message))
+ if gate is not None:
+ gate.pass_words = []
+ gate.answered_by_file_add = False
+ try:
+ list(coder.send_message(message))
+ finally:
+ if gate is not None:
+ words, gate.pass_words = gate.pass_words or [], None
+ if not gate.answered_by_file_add:
+ for w in words:
+ if w.strip():
+ _emit("text", {"text": w})
# aider_edited_files accumulates over the turn; what this pass added is reported now, so
# the cards sit beside the prose that produced them.
edited = sorted(set(coder.aider_edited_files or []) - reported)
@@ -678,6 +762,34 @@ def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
coder.io.user_input(message)
+def _turn_answer(coder, gate: _Gate, before: "set | None", failed: bool) -> str:
+ """The turn's answer: the LAST pass's words, and never words addressed to the driver.
+
+ The result's text is what the gateway stores as the answer, so it is stripped of the
+ edit markup exactly as the text events were; the edits were reported as cards. A last pass
+ whose words the automatic file add answered asked the driver for files it already has, so it
+ answered the person nothing — as _run_turn already kept those words out of the reply. A
+ response that was commands or edit blocks and nothing else leaves no answer once the blocks
+ are cards: the model's last word was a command or an edit, and aider gives it no 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, and turn 2 on hello.txt, 2026-10-19, asked for the file and then wrote only the edit).
+ Said as what happened, not as an answer the model gave: the files it changed, by name, or the
+ commands it ran."""
+ final = strip_edit_blocks(coder.partial_response_content or "")
+ if gate.answered_by_file_add:
+ final = ""
+ if not final.strip() and not failed and (gate.calls or coder.aider_edited_files):
+ 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.")
+ return final
+
+
def _write_model_metadata(cwd: str, model: str) -> str | None:
"""Give aider back the model record that the `openai/` prefix hides from it.
@@ -862,6 +974,7 @@ def main() -> int:
# defaults, so the attribute is set on the object, which is what format_chat_chunks reads.
coder.main_model.examples_as_sys_msg = True
_new_files_need_no_add(coder)
+ _added_files_without_invitation()
_repo_map_after_the_conversation(coder)
# NO TEMPERATURE. aider sends `temperature: 0` for every id its settings do not know, and a
# provider that has retired the field refuses the whole turn: claude-fable-5-1 on TokenRouter
@@ -891,23 +1004,7 @@ def main() -> int:
# more of the model's work is not a failed turn: measured 2026-09-19, a restyled .pptx and an
# edited hello.md were reported FAILED for a decode error twelve commands earlier.
failed = coder.usage_report is None or gate.error_after_output
- # The result's text is what the gateway stores as the answer, so it is stripped of the
- # edit markup exactly as the text events were; the edits were reported as cards.
- final = strip_edit_blocks(coder.partial_response_content or "")
- if not final.strip() and not failed and (gate.calls or coder.aider_edited_files):
- # A response that was commands or edit blocks and nothing else leaves no answer once the
- # blocks are cards: the model's last word was a command or an edit, and aider gives it no
- # 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 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.")
+ final = _turn_answer(coder, gate, before, failed)
_emit("result", {
"final": final,
"ok": not failed,
diff --git a/runner/tests/test_aider_driver.py b/runner/tests/test_aider_driver.py
index 9dad46b0..73f0e9b9 100644
--- a/runner/tests/test_aider_driver.py
+++ b/runner/tests/test_aider_driver.py
@@ -627,6 +627,186 @@ def test_a_request_for_words_back_answered_by_an_edit_alone_is_nudged_once():
assert not a("<conversation_so_far>\nuser: say hi\n</conversation_so_far>\n\nCreate hello.txt")
+def _answered_mention_coder(root):
+ """A Coder whose send_message is ordered as 0.86.2 orders it: the display reaches
+ io.assistant_output during the send, then check_for_file_mentions runs, and an ANSWERED
+ mention sets the reflected message and ends the pass before any edit or command
+ (base_coder.py:1561-1567). `mentions` holds what the check returns, one entry per pass."""
+ class Coder:
+ def __init__(self, replies, mentions):
+ self.replies = list(replies); self.mentions = list(mentions)
+ self.reflected_message = None; self.partial_response_content = ""
+ self.aider_edited_files = set(); self.max_reflections = 5; self.root = root
+ self.io = types.SimpleNamespace(user_input=lambda p: None,
+ assistant_output=lambda m, pretty=None: None,
+ confirm_ask=lambda *a, **k: True,
+ tool_error=lambda m="", strip=True: None,
+ tool_warning=lambda m="", strip=True: None)
+ self.sent = []
+ def check_for_file_mentions(self, content):
+ # aider's own: an answered mention returns prompts.added_files, else None
+ return self.mentions.pop(0) if self.mentions else None
+ def init_before_message(self): pass
+ def send_message(self, m):
+ self.sent.append(m)
+ self.partial_response_content = self.replies.pop(0)
+ self.io.assistant_output(self.partial_response_content)
+ added = self.check_for_file_mentions(self.partial_response_content)
+ if added:
+ self.reflected_message = added
+ return iter(())
+ if "<<<<<<< SEARCH" in self.partial_response_content:
+ self.aider_edited_files.add("hello.txt")
+ pathlib.Path(self.root, "hello.txt").write_text("hello\nworld\n")
+ return iter(())
+ return Coder
+
+
+def _run_installed(coder, prompt):
+ """_install + _run_turn on one gate, with every event the turn emits captured."""
+ gate = aider_driver._Gate([])
+ emitted: list = []
+ real_emit = aider_driver._emit
+ aider_driver._emit = lambda m, p: emitted.append((m, p))
+ try:
+ aider_driver._install(coder, gate)
+ aider_driver._run_turn(coder, prompt, gate)
+ finally:
+ aider_driver._emit = real_emit
+ return gate, emitted
+
+
+# what check_for_file_mentions returns once the driver has set prompts.added_files: the reflected
+# message the driver feeds back IS this string (the shape tests below assert it in c.sent)
+_ADDED = aider_driver.ADDED_FILES.format(fnames="hello.txt")
+_BLOCK = "hello.txt\n```text\n<<<<<<< SEARCH\nhello\n=======\nhello\nworld\n>>>>>>> REPLACE\n```\n"
+
+
+def test_a_pass_answered_by_the_automatic_file_add_is_not_part_of_the_reply(tmp_path):
+ """MEASURED twice on the hosted service (gpt-5.4, QA org, 2026-10-19), then 9 of 12 across
+ gpt-5.4, gpt-5.5 and gpt-6-sol on 0.35.8: turn 2 of hello.txt ("add a second line, world, to
+ hello.txt") rendered (1) "Please add this file to the chat first so I can provide an exact
+ edit: - `hello.txt`" (2) the edit (3) an empty message. The first pass's words were answered
+ by the driver itself — check_for_file_mentions added the file and set the reflected message —
+ so the person read a request nobody needs to act on; the second pass was the edit block alone,
+ an empty message once the block is a card. The pass that spoke to the driver is not part of
+ the reply, an empty text is never emitted, and the answer is the sentence from the edits. The
+ add request's WORDING varies by model, so the detection is the mechanism (the check returned
+ its added-files message), never the words: a second wording must behave the same."""
+ Coder = _answered_mention_coder(str(tmp_path))
+ ask = "add a second line, world, to hello.txt"
+ c = Coder(["Please add this file to the chat first so I can provide an exact edit:\n- `hello.txt`",
+ _BLOCK], [_ADDED, None])
+ gate, emitted = _run_installed(c, ask)
+ assert c.sent == [ask, _ADDED] # the add was answered, aider's own loop ran
+ texts = [p["text"] for m, p in emitted if m == "text"]
+ assert texts == [] # no add-file text, and never an empty message
+ assert ("edits", {"files": ["hello.txt"]}) in emitted
+ assert aider_driver._turn_answer(c, gate, {"hello.txt"}, failed=False) == "Edited hello.txt."
+ # another wording of the same request (gpt-5.5 and gpt-6-sol write their own): the mechanism
+ # decides, so the words never matter
+ c = Coder(["I need to edit this existing file, which has not been added to the chat yet: hello.txt",
+ _BLOCK], [_ADDED, None])
+ gate, emitted = _run_installed(c, ask)
+ assert [p["text"] for m, p in emitted if m == "text"] == []
+ assert aider_driver._turn_answer(c, gate, {"hello.txt"}, failed=False) == "Edited hello.txt."
+ # off the send path too, an empty text is never emitted: a display of edit blocks alone is
+ # no message at all, not ""
+ assert _turn_texts(_BLOCK, "") == []
+
+
+def test_the_last_pass_words_are_the_answer_and_win_over_the_edits_sentence(tmp_path):
+ """The sentence is the fallback, not the answer: a last pass that wrote the edit AND words
+ answers with its words, and a request that asks for words back still gets its one REPLY_NUDGE
+ first — the nudged words are the answer, the sentence stays behind them."""
+ Coder = _answered_mention_coder(str(tmp_path))
+ ask = "add a second line, world, to hello.txt"
+ c = Coder(["Please add `hello.txt` to the chat so I can edit it.",
+ _BLOCK + "\nAdded the second line."], [_ADDED, None])
+ gate, emitted = _run_installed(c, ask)
+ assert [p["text"] for m, p in emitted if m == "text"] == ["Added the second line."]
+ assert aider_driver._turn_answer(c, gate, {"hello.txt"}, failed=False) == "Added the second line."
+ # asked for words back and the edit pass wrote none: one nudge, and the nudged word answers
+ asked = ask + ", then say done."
+ c = Coder(["Please add `hello.txt` to the chat so I can edit it.", _BLOCK, "done"],
+ [_ADDED, None, None])
+ gate, emitted = _run_installed(c, asked)
+ assert c.sent == [asked, _ADDED, aider_driver.REPLY_NUDGE]
+ assert [p["text"] for m, p in emitted if m == "text"] == ["done"]
+ assert aider_driver._turn_answer(c, gate, {"hello.txt"}, failed=False) == "done"
+ # a turn whose TAIL asked the driver for files (reflections spent) answers with what it did,
+ # never with that request; a failed turn keeps its empty answer for the error to speak
+ ns = types.SimpleNamespace(partial_response_content="Please add `notes.md` to the chat.",
+ aider_edited_files={"hello.txt"})
+ g = aider_driver._Gate([]); g.answered_by_file_add = True
+ assert aider_driver._turn_answer(ns, g, {"hello.txt"}, failed=False) == "Edited hello.txt."
+ assert aider_driver._turn_answer(ns, g, {"hello.txt"}, failed=True) == ""
+ g.calls.append({"command": "cat hello.txt", "tool": "Shell", "approved": True, "reason": ""})
+ assert aider_driver._turn_answer(ns, g, {"hello.txt"}, failed=False) == \
+ "Edited hello.txt. The commands and their output are above."
+ g.answered_by_file_add = False
+ assert aider_driver._turn_answer(ns, g, {"hello.txt"}, failed=False) == "Please add `notes.md` to the chat."
+
+
+def test_mid_turn_words_that_no_file_add_answered_keep_their_message_and_their_place(tmp_path):
+ """The words of every pass the file add did not answer stay what they are today: each pass its
+ own message, ahead of the cards it narrates (the gate flushes the parked words when a card
+ goes out). They remain narration — the turn's answer is still the LAST pass's words alone,
+ never a join of the passes."""
+ Coder = _answered_mention_coder(str(tmp_path))
+
+ class Narrating(Coder):
+ def send_message(self, m):
+ out = super().send_message(m)
+ if len(self.sent) == 1: # the first pass proposes a command, aider confirms it
+ self.io.confirm_ask("Run shell command?", subject="cat hello.txt",
+ explicit_yes_required=True)
+ self.reflected_message = "Output:\n\ntwo lines\n\n" + aider_driver.REFLECT_ASK
+ return out
+ c = Narrating(["Reading the file now.", "hello.txt has two lines."], [None, None])
+ gate, emitted = _run_installed(c, "how many lines does hello.txt have?")
+ order = [(m, p.get("text") or p.get("command")) for m, p in emitted
+ if m in ("text", "shell_decision")]
+ assert order == [("text", "Reading the file now."),
+ ("shell_decision", "cat hello.txt"),
+ ("text", "hello.txt has two lines.")]
+ assert aider_driver._turn_answer(c, gate, set(), failed=False) == "hello.txt has two lines."
+
+
+def test_the_added_files_message_states_the_add_and_invites_no_answer():
+ """aider's own added_files prompt ends "Let me know if there are others we should add." — an
+ invitation written for a person at the prompt. Reflected into the driver's loop it was
+ ANSWERED: gpt-6-sol opened the pass after the add with "No other files are needed." and that
+ narration became the turn's answer, in the future tense ("I'll add `there` after `hi`.",
+ rc.1 probe, 2026-10-19). The driver's message states the add and points back at the request —
+ no question, no invitation — and it lives on the aider.prompts MODULE, because that is where
+ check_for_file_mentions reads it (base_coder.py:31, 1781); the coder's gpt_prompts does not
+ carry it."""
+ assert aider_driver.ADDED_FILES.format(fnames="hello.txt") == \
+ "I added these files to the chat: hello.txt. Continue with the request."
+ msg = aider_driver.ADDED_FILES.format(fnames="a.txt, b.txt")
+ assert "a.txt, b.txt" in msg and "?" not in msg and "Let me know" not in msg
+ # the override lands where aider reads it, replacing aider's own wording
+ pkg = types.ModuleType("aider")
+ mod = types.ModuleType("aider.prompts")
+ mod.added_files = ("I added these files to the chat: {fnames}\nLet me know if there are others"
+ " we should add.")
+ pkg.prompts = mod
+ saved = {k: sys.modules.get(k) for k in ("aider", "aider.prompts")}
+ sys.modules.update({"aider": pkg, "aider.prompts": mod})
+ try:
+ aider_driver._added_files_without_invitation()
+ finally:
+ for k, v in saved.items():
+ sys.modules.pop(k, None) if v is None else sys.modules.__setitem__(k, v)
+ assert mod.added_files == aider_driver.ADDED_FILES
+ src = pathlib.Path(__file__).resolve().parents[1].joinpath("aider_driver.py").read_text()
+ assert " _added_files_without_invitation()\n" in src # main sets it before the turn runs
+ # _ADDED above is this message, so the shape tests also pin that the reflected message the
+ # driver feeds back is the uninviting one
+ assert _ADDED == aider_driver.ADDED_FILES.format(fnames="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