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.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
Aider: a reply that is only reasoning says so, instead of showing aider's banner (#412)
Jiaqiiii52320ea17b5a773
diff --git a/runner/aider_driver.py b/runner/aider_driver.pyindex 1d221307..59ab13d6 100644--- a/runner/aider_driver.py+++ b/runner/aider_driver.py@@ -98,6 +98,30 @@ def strip_edit_blocks(text: str) -> str:return _strip_shell_blocks(_EDIT_BLOCK.sub("", text or "")).strip()+NO_ANSWER = "The model wrote only its reasoning; there was no answer this turn."+++def _after_answer_banner(display: str) -> str:+ """The answer half of aider's display string, or the statement that the model wrote none.++ This is the fallback when `partial_response_content` is empty, and `remove_reasoning_content`+ cannot serve it: that helper looks for `<tag>`/`</tag>`, and `replace_reasoning_tags` has+ already rewritten them into the `► **THINKING**` / `► **ANSWER**` furniture (reasoning_tags.py:8-11)+ that the reader then saw as the answer. MEASURED on kimi-k3, about one aider turn in three+ returned reasoning and no content at all (#395), so the furniture is what came back. Everything+ after aider's own ANSWER banner IS the answer; when nothing follows, the model wrote none and+ this says so rather than quoting the banner. A display string with no banner at all is some other+ call site off the send path and still reports what it passed, as it did before this helper.+ """+ try:+ from aider.reasoning_tags import REASONING_END+ except Exception:+ return display+ if REASONING_END not in display:+ return display+ return display.split(REASONING_END)[-1].strip() or NO_ANSWER++def is_text_file(path: str, sniff: int = 65536) -> bool:"""Whether aider could read this file as text. aider adds a file the model names and reads itas UTF-8; a binary one (a .pptx the model was asked to restyle, 2026-09-19 on hr-test) fails@@ -211,8 +235,10 @@ def _install(coder, gate: _Gate) -> None:coder.reasoning_tag_name)except Exception:body = ""+ # 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 str(message))})+ _emit("text", {"text": strip_edit_blocks(body or _after_answer_banner(str(message)))})return orig_assistant(message, pretty)def tool_error(message="", strip=True):diff --git a/runner/tests/test_aider_driver.py b/runner/tests/test_aider_driver.pyindex e3263148..3c89775d 100644--- a/runner/tests/test_aider_driver.py+++ b/runner/tests/test_aider_driver.py@@ -806,6 +806,91 @@ def test_each_text_pass_ends_with_a_paragraph_break():assert ev["message"]["content"][0]["text"] == "First pass.\n\n"+def _stub_reasoning_tags():+ """aider's `reasoning_tags` as the suite sees it: the suite runs without aider installed, so+ the two display markers and the strip helper stand in here. The markers are aider 0.86.2's own+ literals (reasoning_tags.py:8-11), copied so a reworded banner upstream shows as a red test."""+ import re as _re+ pkg = types.ModuleType("aider")+ mod = types.ModuleType("aider.reasoning_tags")+ mod.REASONING_START = "--------------\n► **THINKING**"+ mod.REASONING_END = "------------\n► **ANSWER**"+ mod.remove_reasoning_content = lambda res, tag: (+ _re.sub(f"<{tag}>.*?</{tag}>", "", res, flags=_re.DOTALL).strip() if tag else res)+ pkg.reasoning_tags = mod+ return {"aider": pkg, "aider.reasoning_tags": mod}+++def _turn_texts(display: str, content: str) -> list[str]:+ """What the driver emits as the turn's text for one aider response."""+ class _IO:+ def assistant_output(self, message, pretty=None): pass+ def confirm_ask(self, *a, **k): return True+ def tool_error(self, *a, **k): pass+ def tool_warning(self, *a, **k): pass++ coder = types.SimpleNamespace(io=_IO(), partial_response_content=content,+ reasoning_tag_name="thinking-content-7bbeb8e1441453ad999a0bbba8a46d4b",+ shell_commands=[])+ stub = _stub_reasoning_tags()+ emitted: list = []+ real_emit = aider_driver._emit+ saved = {k: sys.modules.get(k) for k in stub}+ sys.modules.update(stub)+ try:+ aider_driver._emit = lambda m, p: emitted.append((m, p))+ aider_driver._install(coder, aider_driver._Gate([]))+ coder.io.assistant_output(display)+ finally:+ aider_driver._emit = real_emit+ for k, v in saved.items():+ sys.modules.pop(k, None) if v is None else sys.modules.__setitem__(k, v)+ return [p["text"] for m, p in emitted if m == "text"]+++def test_a_reply_of_reasoning_only_says_the_model_wrote_no_answer():+ """MEASURED FAILURE this pins (self-hosted, kimi-k3, 2026-10-05, #395): about one aider turn in+ three the model returned reasoning and no content, the turn completed, and the answer the reader+ got was aider's own display furniture — `--------------\\n► **THINKING**` and the chain of+ thought — because an empty `partial_response_content` falls back to the display string, and+ `remove_reasoning_content` only recognises the `<tag>` form the display string no longer holds."""+ furniture = (_stub_reasoning_tags()["aider.reasoning_tags"].REASONING_START+ + "\n\nThe user wants me to call the MCP tool `probe_rows`. Let me first check"+ " the tools available on the probe server.\n\n"+ + _stub_reasoning_tags()["aider.reasoning_tags"].REASONING_END + "\n\n")+ texts = _turn_texts(furniture, "")+ assert texts == [aider_driver.NO_ANSWER], texts+ assert "THINKING" not in texts[0] and "►" not in texts[0]+ # what the gateway stores is the result's text; the normaliser takes the last text pass when+ # the driver's own `final` is empty, so the banner reached the record through that door too+ state: dict = {"_aider_init": True}+ _aider_to_claude({"m": "text", "p": {"text": texts[0]}}, state)+ ev = _aider_to_claude({"m": "result", "p": {"ok": True, "final": ""}}, state)[0]+ assert ev["is_error"] is False and ev["result"] == aider_driver.NO_ANSWER+++def test_the_answer_behind_the_banner_is_what_the_reader_gets():+ """The other half of the same fallback: a content field that is empty does not mean the display+ string holds nothing but reasoning — what follows aider's ANSWER marker is the answer."""+ stub = _stub_reasoning_tags()["aider.reasoning_tags"]+ display = (stub.REASONING_START + "\n\nthink think think\n\n" + stub.REASONING_END+ + "\n\nA one-pager is in sfo.pdf.\n")+ assert _turn_texts(display, "") == ["A one-pager is in sfo.pdf."]+++def test_a_display_string_with_no_furniture_is_reported_as_it_arrived():+ """The fallback exists for a call site off the send path, which passes plain prose; stripping+ to nothing there would answer the reader with silence (the invariant in `_install`'s comment)."""+ assert _turn_texts("I restyled the deck.", "") == ["I restyled the deck."]+++def test_the_driver_takes_aiders_own_banner():+ """Handing the marker to the helper is the point: a pattern of ours would drift from aider's."""+ src = pathlib.Path(__file__).resolve().parents[1].joinpath("aider_driver.py").read_text()+ assert "from aider.reasoning_tags import REASONING_END" in src+ assert "body or _after_answer_banner(str(message))" in src++def test_the_models_reasoning_is_not_rendered_as_its_answer():"""MEASURED FAILURE this pins (vercel|aider|grok-4.20, 2026-09-18): the transcript showed themodel's chain of thought -- "(wait, no, that's not how it works)... So my response should be:"@@ -828,17 +913,13 @@ def test_the_models_reasoning_is_not_rendered_as_its_answer():coder = _Coder()emitted = []real_emit = aider_driver._emit- aider_driver._emit = lambda m, p: emitted.append((m, p))# the driver asks aider to strip, so aider is where the tag semantics stay; the suite runs# without aider installed, so its helper stands in here- import re as _re- pkg = types.ModuleType("aider"); mod = types.ModuleType("aider.reasoning_tags")- mod.remove_reasoning_content = lambda res, tag: (- _re.sub(f"<{tag}>.*?</{tag}>", "", res, flags=_re.DOTALL).strip() if tag else res)- pkg.reasoning_tags = mod- saved = {k: sys.modules.get(k) for k in ("aider", "aider.reasoning_tags")}- sys.modules.update({"aider": pkg, "aider.reasoning_tags": mod})+ stub = _stub_reasoning_tags()+ saved = {k: sys.modules.get(k) for k in stub}+ sys.modules.update(stub)try:+ aider_driver._emit = lambda m, p: emitted.append((m, p))aider_driver._install(coder, aider_driver._Gate([]))# what aider would hand it for a reasoning modelcoder.io.assistant_output(