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: an edit block's file name is stripped with the whitespace and the blank line aider's parser allows (#531)

github-actions[bot]caa3c0a109ff
diff --git a/runner/aider_driver.py b/runner/aider_driver.py
index 53ffdab9..a347116c 100644
--- a/runner/aider_driver.py
+++ b/runner/aider_driver.py
@@ -55,8 +55,17 @@ _T0 = time.time()
# Fences are three OR MORE backticks: aider's own parser takes any length (a block whose content
# holds ``` is fenced with ````), and gpt-5.4 closes with four. A stripper that took exactly three
# left the fourth behind as the whole answer (an answer card reading "`", hosted 2026-09-19).
-_EDIT_BLOCK = re.compile(r"(?:^\S+\n)?`{3,}[^\n]*\n(?:\S+\n)?<{5,9} SEARCH\n.*?^>{5,9} REPLACE\n`{3,}[ \t]*\n?",
- re.S | re.M)
+# The file name tolerates what aider's parser tolerates: find_filename reads the 3 lines before
+# `<<<<<<< SEARCH` and strips each one (editblock_coder.py:492, 538-569; strip_filename:408), so a
+# name with whitespace around it, or one blank line between it and the fence, still names the
+# block's file — gpt-5.4 wrote both shapes and the leftover "hello.txt" beat the edits sentence as
+# the whole answer (hosted, 2026-10-19). One token only (\S+): a line with internal spaces is
+# prose and is never swallowed, and a second blank line puts the name outside the parser's 3-line
+# window, so it stays.
+_EDIT_BLOCK = re.compile(
+ r"(?:^[ \t]*\S+[ \t]*\n(?:[ \t]*\n)?)?`{3,}[^\n]*\n(?:[ \t]*\S+[ \t]*\n)?<{5,9} SEARCH\n"
+ r".*?^>{5,9} REPLACE\n`{3,}[ \t]*\n?",
+ re.S | re.M)
# `hr-mcp call <server> <tool>` wherever it stands in COMMAND position: at the start of the line
diff --git a/runner/tests/test_aider_driver.py b/runner/tests/test_aider_driver.py
index 73f0e9b9..a956b924 100644
--- a/runner/tests/test_aider_driver.py
+++ b/runner/tests/test_aider_driver.py
@@ -322,6 +322,33 @@ def test_edit_blocks_are_stripped_from_the_answer_and_the_edits_render_as_cards(
assert 'final = strip_edit_blocks(coder.partial_response_content or "")' in src
+def test_a_path_line_aiders_lookback_takes_is_stripped_with_its_block():
+ """gpt-5.4 answered just "hello.txt" (1 of 3 follow-up probes, hosted, 2026-10-19): it set the
+ path line off from the fence — a blank line between them, or a trailing space on the name —
+ and aider still applied the edit, because find_filename reads the 3 lines before
+ `<<<<<<< SEARCH` and strips each one (editblock_coder.py:492, 538-569; strip_filename:408),
+ while the strip's path group took only a bare \\S+ line DIRECTLY above the fence. The leftover
+ path then beat the edits sentence as the answer. The group now takes what the parser takes:
+ whitespace around the name, one blank line at most (the parser's 3-line window holds no more),
+ and still one token only, so a prose line is never swallowed."""
+ S = aider_driver.strip_edit_blocks
+ block = "```text\n<<<<<<< SEARCH\nhello\n=======\nhello\nworld\n>>>>>>> REPLACE\n```\n"
+ assert S("hello.txt\n\n" + block) == "" # path + blank line + fence (measured)
+ assert S("hello.txt \n" + block) == "" # trailing space on the path (measured)
+ assert S("hello.txt\t\n" + block) == ""
+ assert S(" hello.txt\n" + block) == "" # leading spaces: strip_filename strips
+ assert S("hello.txt \n \n" + block) == "" # a whitespace-only line is a blank one
+ assert S("Done.\n\nhello.txt\n\n" + block) == "Done." # prose above the path is kept
+ # a second blank line puts the path outside find_filename's window: it is not the block's
+ assert S("hello.txt\n\n\n" + block) == "hello.txt"
+ # a line with internal spaces is prose, never a path, whatever sits under it
+ assert S("I will edit hello.txt now.\n" + block) == "I will edit hello.txt now."
+ assert S("I will edit hello.txt now.\n\n" + block) == "I will edit hello.txt now."
+ # the name inside the fence tolerates the same whitespace, and the whole block still matches
+ inside = "```python\nbuild.py \n<<<<<<< SEARCH\n=======\nx = 1\n>>>>>>> REPLACE\n```\n"
+ assert S("Deck builder:\n" + inside) == "Deck builder:"
+
+
def test_a_turn_that_ended_on_a_command_says_so_rather_than_saying_nothing():
"""A response that was commands and nothing else leaves no answer once the blocks are cards;
the record then read as an empty reply (hosted, 2026-09-19: seven officecli attempts, no text,