fix(stall_watch): call herdr with the sanitized agent name (Issue #66)

herdr registers an agent under sanitize_herdr_agent_name(session), so a
session name over 32 characters or with upper-case letters got
agent_not_found and stall detection went off. stall_watch now converts the
name for every herdr call (agent get/read/prompt, watcher.wait_once); logs
and notices keep the original name, and the agent kind is still read off
the original suffix (a long name's sanitized form ends in a hash).

The conftest mock herdr gets an opt-in strict_agent_names mode that, like
the real herdr, answers an agent only under its registered name and fails
get/read with agent_not_found JSON; existing tests see no change.

Refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-24 13:47:54 +00:00
1 parent 0461a632eb
commit bb496fde78
3 files changed
+150 -5

No files matched your search

+11
View File
@@ -470,6 +470,9 @@ def _sanitize_agent_name(name):
def _match_agent(k, target):
if not k or not target:
return False
# Issue #66: like the real herdr, answer only the registered (sanitized) name.
if state.get("strict_agent_names"):
return k == target
return k == target or _sanitize_agent_name(k) == target or _sanitize_agent_name(target) == k or _sanitize_agent_name(k) == _sanitize_agent_name(target)
args = sys.argv[1:]
@@ -1052,6 +1055,10 @@ elif cmd1 == "agent":
}))
sys.exit(0)
else:
if state.get("strict_agent_names"):
sys.stderr.write(json.dumps({"error": {"code": "agent_not_found",
"message": "agent " + name + " not found"}}) + "\\n")
sys.exit(1)
sys.stderr.write("Agent " + name + " not found\\n")
sys.exit(1)
elif cmd2 == "wait":
@@ -1143,6 +1150,10 @@ elif cmd1 == "agent":
print(buffer_content)
sys.exit(0)
else:
if state.get("strict_agent_names"):
sys.stderr.write(json.dumps({"error": {"code": "agent_not_found",
"message": "agent " + name + " not found"}}) + "\\n")
sys.exit(1)
sys.stderr.write("Agent " + name + " not found\\n")
sys.exit(1)
elif cmd2 == "prompt":