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: its no-files messages say a new file is written directly when a request asks for one (#502)

Arun Prabhakarane345bc788c55
diff --git a/runner/aider_driver.py b/runner/aider_driver.py
index 4ad6df01..a437bc3e 100644
--- a/runner/aider_driver.py
+++ b/runner/aider_driver.py
@@ -34,6 +34,7 @@ from __future__ import annotations
import codecs
import contextlib
+import copy
import json
import os
import pathlib
@@ -487,6 +488,68 @@ def _file_nudge(names: list) -> str:
"asks for.")
+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 "
+ "answered in words, without creating it.")
+
+
+def _new_files_need_no_add(coder) -> None:
+ """aider's word for a chat with no files in it is "I am not sharing any files that you can
+ edit yet.", sent as the user every turn. gpt-5.4-mini took it at its word (#379): asked to
+ create hello-aider.txt it answered "I can't create or edit files yet because you haven't
+ shared any editable files in the chat", and said it again after the nudge, and after a second
+ nudge tried for measuring. With the workspace notes' line and the nudge it wrote the file 12 of
+ 17 times and 6 answered that way; with this message as well, 21 of 24 and none (2026-10-18).
+
+ When the workspace has files aider sends another: "Don't try and edit any existing code without
+ asking me to add the files to the chat! ... then stop so I can add them", answered for the
+ model with "I will suggest which files need to be edited and then stop and wait for your
+ approval". With notes.md and src/app.py in the workspace gpt-5.4-mini wrote the file 1 of 6
+ (0 of 3 on the build before this change). That one keeps its rule for existing files, which
+ the driver's adding of named files answers, and says a new file is written directly: 4 of 6,
+ gpt-5.4 2 of 2, and appending to notes.md still worked (gpt-5.4 2 of 2). The prompts object is
+ the coder class's own, shared, so it is copied first."""
+ prompts = copy.copy(coder.gpt_prompts)
+ prompts.files_no_full_files = "No files are in the chat yet. " + NEW_FILE_NOTE
+ if getattr(prompts, "files_no_full_files_with_repo_map", None):
+ prompts.files_no_full_files_with_repo_map = (
+ "No files are in the chat yet. " + NEW_FILE_NOTE + "\n"
+ "An existing file has to be in the chat before you edit it: to change existing files, "
+ "name the ones that need changes and stop, and they will be added. Name only files "
+ "that need to be edited, not ones that are only context.\n")
+ prompts.files_no_full_files_with_repo_map_reply = (
+ "Ok. If a request asks for a new file I will write it directly; for existing files I "
+ "will name the ones that need changes and stop so they can be added.")
+ coder.gpt_prompts = prompts
+
+
+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
+ edit those files without asking first.", AHEAD of the restored conversation (format_chat_chunks
+ puts repo before done), so once the workspace holds a file the first exchange the model sees is
+ aider's. Asked what word the first message of the task asked for, gpt-5.4 answered "Ok" or
+ "exactly" 5 of 6 times after it had written hello-aider.txt, and "M1-gpt-5.4" 6 of 6 with the
+ map moved (0.35.3-rc.4, 2026-10-18). The examples were moved out of the conversation for the
+ same reason. The map now opens the files message that follows
+ the conversation, where the note on what is in the chat already sits: what the model is told
+ about the workspace is the same, only its place moves."""
+ repo_messages = coder.get_repo_messages
+ files_messages = coder.get_chat_files_messages
+
+ def chat_files():
+ files, repo = files_messages(), repo_messages()
+ if not repo:
+ return files
+ if files and files[0]["role"] == "user" and isinstance(files[0]["content"], str):
+ return [dict(files[0], content=repo[0]["content"] + "\n\n" + files[0]["content"])] + files[1:]
+ return repo + files
+
+ coder.get_repo_messages = lambda: []
+ coder.get_chat_files_messages = chat_files
+
+
def _run_turn(coder, prompt: str, gate: "_Gate | None" = None) -> None:
"""aider's own reflection loop (Coder.run_one), driven directly.
@@ -740,6 +803,8 @@ def main() -> int:
# a per-model settings file would replace every other setting of the model with the class
# 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)
+ _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
# answered "`temperature` is deprecated for this model" and the turn died after 171 s of
diff --git a/runner/tests/test_aider_driver.py b/runner/tests/test_aider_driver.py
index 0fb77299..b6ac5411 100644
--- a/runner/tests/test_aider_driver.py
+++ b/runner/tests/test_aider_driver.py
@@ -550,6 +550,65 @@ 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_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
+ an empty SEARCH; the repo-map message keeps aider's text and gains that sentence; aider's
+ shared prompts object is left as it was."""
+ class Prompts:
+ files_no_full_files = "I am not sharing any files that you can edit yet."
+ files_no_full_files_with_repo_map = "Don't try and edit any existing code without asking me to add the files to the chat!\n"
+ files_no_full_files_with_repo_map_reply = "Ok, based on your requests I will suggest which files need to be edited and then stop and wait for your approval."
+ shared = Prompts()
+ coder = types.SimpleNamespace(gpt_prompts=shared)
+ aider_driver._new_files_need_no_add(coder)
+ p = coder.gpt_prompts
+ assert "not sharing" not in p.files_no_full_files and aider_driver.NEW_FILE_NOTE in p.files_no_full_files
+ # with a repo map: a new file is written directly; an existing one is still named and added
+ assert aider_driver.NEW_FILE_NOTE in p.files_no_full_files_with_repo_map
+ assert "name the ones that need changes and stop" in p.files_no_full_files_with_repo_map
+ assert "wait for your approval" not in p.files_no_full_files_with_repo_map_reply
+ assert "write it directly" in p.files_no_full_files_with_repo_map_reply
+ # conditional on a request for a file: a question about one is answered, not acted on (on
+ # 0.35.3-rc.2 an unconditional note made gpt-5.4, gpt-5.5 and gpt-6-sol create the file asked about)
+ assert "If the request asks for a new file" in aider_driver.NEW_FILE_NOTE
+ assert "A question about a file is answered in words" in aider_driver.NEW_FILE_NOTE
+ assert shared.files_no_full_files == "I am not sharing any files that you can edit yet."
+ assert shared.files_no_full_files_with_repo_map.startswith("Don't try")
+ # a coder whose prompts have no repo-map message (aider's ask and architect modes) keeps none
+ bare = types.SimpleNamespace(gpt_prompts=types.SimpleNamespace(
+ files_no_full_files="x", files_no_full_files_with_repo_map="", files_no_full_files_with_repo_map_reply=""))
+ aider_driver._new_files_need_no_add(bare)
+ assert bare.gpt_prompts.files_no_full_files_with_repo_map == ""
+ src = pathlib.Path(__file__).resolve().parents[1].joinpath("aider_driver.py").read_text()
+ assert " _new_files_need_no_add(coder)\n" in src
+
+
+def test_the_repo_map_follows_the_conversation():
+ """With a file in the workspace aider's repo map and its canned "Ok, I won't try..." reply came
+ ahead of the conversation, and gpt-5.4 asked for the first message's word answered "Ok" 5 of 6
+ times (0.35.3-rc.4). The map now opens the files message after the conversation; nothing of it
+ is dropped, and a workspace with no map is left as it was."""
+ repo = [dict(role="user", content="Here are summaries of some files present in my git repository.\nhello-aider.txt"),
+ dict(role="assistant", content="Ok, I won't try and edit those files without asking first.")]
+ files = [dict(role="user", content="No files are in the chat yet."), dict(role="assistant", content="Ok.")]
+ coder = types.SimpleNamespace(get_repo_messages=lambda: list(repo), get_chat_files_messages=lambda: list(files))
+ aider_driver._repo_map_after_the_conversation(coder)
+ assert coder.get_repo_messages() == []
+ msgs = coder.get_chat_files_messages()
+ assert [m["role"] for m in msgs] == ["user", "assistant"]
+ assert msgs[0]["content"].startswith("Here are summaries") and msgs[0]["content"].endswith("No files are in the chat yet.")
+ assert "hello-aider.txt" in msgs[0]["content"] and msgs[1]["content"] == "Ok."
+ empty = types.SimpleNamespace(get_repo_messages=lambda: [], get_chat_files_messages=lambda: list(files))
+ aider_driver._repo_map_after_the_conversation(empty)
+ assert empty.get_chat_files_messages() == files # an empty workspace: as before
+ none = types.SimpleNamespace(get_repo_messages=lambda: list(repo), get_chat_files_messages=lambda: [])
+ aider_driver._repo_map_after_the_conversation(none)
+ assert none.get_chat_files_messages() == repo # no files message: the map alone
+ src = pathlib.Path(__file__).resolve().parents[1].joinpath("aider_driver.py").read_text()
+ assert " _repo_map_after_the_conversation(coder)\n" in src
+
+
def test_agent_doc_is_written_as_agents_md_even_though_aider_reads_it_via_read():
assert _agent_doc_path("/ws", "aider").name == "AGENTS.md"