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.

cheetahclaws: a failure reason that names a path is kept (#490)

Rudy Mizrahi Celekli87e51b13d1c4
diff --git a/runner/cheetahclaws_driver.py b/runner/cheetahclaws_driver.py
index 0fe278b9..cbb0b693 100644
--- a/runner/cheetahclaws_driver.py
+++ b/runner/cheetahclaws_driver.py
@@ -55,8 +55,9 @@ FAILED_RE = re.compile(r"^\s*\[Failed — (?P<body>.+)\]\s*$", re.S)
# A sentence that sends the reader to the CLI's own slash commands ("Hint: Check your API key:
# /config …", "Try /clear and rephrase …"). The person reading the turn record has no such prompt:
# the rule kimi's "To resume this session" line and aider's "Use /drop" advice already follow. The
-# sentences around it are the reason and stay.
-_SLASH_CMD = re.compile(r"(?:^|\s)/[a-z][\w-]*\b")
+# sentences around it are the reason and stay. A command is one segment: `/home/hr/x.json` or
+# `/v1/models` in an error is a path, and the sentence carrying it is usually the reason itself.
+_SLASH_CMD = re.compile(r"(?:^|\s)/[a-z][\w-]*\b(?!/)")
LOOP_GUARD = "[Loop guard]"
# Withheld on every turn, because none of them can do its job here. AskUserQuestion blocks on the
diff --git a/runner/tests/test_cheetahclaws_backend.py b/runner/tests/test_cheetahclaws_backend.py
index 815c33e5..8b707a5c 100644
--- a/runner/tests/test_cheetahclaws_backend.py
+++ b/runner/tests/test_cheetahclaws_backend.py
@@ -99,6 +99,21 @@ def test_a_hint_that_names_the_clis_slash_commands_is_cut_from_the_reason():
assert r.endswith("check your internet connection or the API endpoint URL.")
+def test_a_path_in_the_reason_is_not_taken_for_a_slash_command():
+ """A sentence naming a path (`/home/hr/x.json`, `/v1/models/foo`) matched the slash-command
+ pattern and was cut, and when it was the only sentence the reason came back empty, so the turn
+ said only that it ended without a completion."""
+ r = drv.failure_reason("[Failed — FileNotFoundError: [Errno 2] No such file or directory: /home/hr/x.json]")
+ assert r == "Failed — FileNotFoundError: [Errno 2] No such file or directory: /home/hr/x.json"
+ r = drv.failure_reason("[Failed — NotFoundError: Error code: 404 at /v1/models/foo]")
+ assert r == "Failed — NotFoundError: Error code: 404 at /v1/models/foo"
+ assert drv.failure_reason("[Loop guard] Model repeated /bin/ls 5 times. Stopping.") == \
+ "Loop guard: Model repeated /bin/ls 5 times. Stopping."
+ # the CLI's own command is still cut, a path beside it or not
+ r = drv.failure_reason("[Failed — NotFoundError: no model at /v1/models/foo. Try /model to pick another.]")
+ assert r == "Failed — NotFoundError: no model at /v1/models/foo."
+
+
def test_the_verdict_is_the_historys_shape_not_the_text():
user = {"role": "user", "content": "hi"}
# a model that WRITES a failure line is still an answer (one completion came back)