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.

zeroclaw: a tool result without rawOutput is its content, not the word "null" (#492)

Rudy Mizrahi Celekli41a28230d526
diff --git a/runner/tests/test_zeroclaw_driver.py b/runner/tests/test_zeroclaw_driver.py
index cec49b12..6f32ebfa 100644
--- a/runner/tests/test_zeroclaw_driver.py
+++ b/runner/tests/test_zeroclaw_driver.py
@@ -316,3 +316,22 @@ def test_only_the_measured_tools_are_offered_and_none_means_none():
with tempfile.TemporaryDirectory() as d:
_, _, cfg = _build(d, tools_disabled=list(srv.ALL_ZEROCLAW_TOOLS))
assert cfg["risk_profiles"]["hr"]["allowed_tools"] == [srv._ZEROCLAW_NO_TOOLS]
+
+
+def test_a_tool_result_without_raw_output_is_its_content_not_the_word_null(monkeypatch):
+ """A terminal tool_call_update with no rawOutput (ACP carries a tool's output in `content`)
+ was reported as json.dumps(None): a tool result reading "null"."""
+ import zeroclaw_driver as zd
+ seen = []
+ monkeypatch.setattr(zd, "_emit", seen.append)
+
+ def result(update):
+ seen.clear()
+ zd._Turn().update({"sessionUpdate": "tool_call_update", "toolCallId": "t1", **update})
+ return seen[0]["message"]["content"][0]["content"]
+
+ blocks = [{"type": "content", "content": {"type": "text", "text": "wrote hello.txt"}}]
+ assert result({"status": "completed", "content": blocks}) == "wrote hello.txt"
+ assert result({"status": "completed"}) == ""
+ assert result({"status": "failed", "rawOutput": "denied"}) == "denied" # unchanged
+ assert result({"status": "completed", "rawOutput": {"ok": True}}) == '{"ok": true}'
diff --git a/runner/zeroclaw_driver.py b/runner/zeroclaw_driver.py
index bcf5b2c7..752341c3 100644
--- a/runner/zeroclaw_driver.py
+++ b/runner/zeroclaw_driver.py
@@ -135,13 +135,31 @@ class _Turn:
# final one repeats.
body = u.get("rawOutput")
if not isinstance(body, str):
- body = u.get("body") if isinstance(u.get("body"), str) else json.dumps(body, default=str)
+ if isinstance(u.get("body"), str):
+ body = u["body"]
+ elif body is None:
+ # No raw output: ACP carries a tool's output in `content` blocks, and
+ # json.dumps(None) put the word "null" in the result instead.
+ body = _tool_content_text(u.get("content"))
+ else:
+ body = json.dumps(body, default=str)
_emit({"type": "user", "message": {"content": [
{"type": "tool_result", "tool_use_id": str(u.get("toolCallId") or "tool"),
"is_error": u.get("status") == "failed", "content": (body or "")[:8000]}]}})
# plan, history_trimmed and the rest are progress for an IDE, not part of the transcript
+def _tool_content_text(content) -> str:
+ """The text of an ACP tool call's content blocks ({"type": "content", "content": {"type":
+ "text", "text": ...}}), "" when there is none."""
+ out = []
+ for block in content if isinstance(content, list) else []:
+ inner = block.get("content") if isinstance(block, dict) else None
+ if isinstance(inner, dict) and isinstance(inner.get("text"), str):
+ out.append(inner["text"])
+ return "\n".join(out)
+
+
def _chunk_text(u: dict) -> str:
c = u.get("content")
if isinstance(c, dict):