Hmbown/CodeWhale · error · RuntimeError
Codewhale stream-json omitted terminal metadata
Error message
Codewhale stream-json omitted terminal metadata
What it means
`_parse_stream_receipt` tracks whether a valid terminal metadata receipt was seen; if the stream ends without ever capturing one, it raises this error. The harness refuses to report a result without the attested terminal receipt (hashes of binary and prompt), because the run cannot be verified.
Solutions
- Re-run and capture the full stream to confirm the process survived to the end (a `done` event must also be present)
- Upgrade the Codewhale binary to a build that emits terminal metadata receipts
- Check stderr/exit code of the launched process for a crash that truncated the stream
- If piping output, verify no buffering/truncation drops the final metadata and done events
Example fix
// before (stream ends early)
{"type":"item",...}
// after (complete stream)
{"type":"item",...}
{"type":"metadata","meta":{"receipt_kind":"terminal","binary_sha256":"...","prompt_sha256":"..."}}
{"type":"done"} Defensive patterns
Strategy: validation
Validate before calling
types = [e.get("type") for e in events]
assert "metadata" in types, "stream lacks terminal metadata receipt"
assert types and types[-1] == "done", "stream did not finish" Try / catch
try:
receipt = _parse_stream_receipt(events)
except RuntimeError as e:
if "omitted terminal metadata" in str(e):
log.error("agent stream ended before terminal receipt; check process exit/stderr")
raise Prevention
- Check agent process exit code and stderr on every run
- Avoid killing/truncating the agent mid-stream
- Verify no output piping drops the last lines
- Use binary versions that emit the terminal receipt
When it happens
Trigger: `launch()` consumes a stream-json that contains no `metadata` event at all, or only metadata events that failed the terminal check, and the loop completes with `terminal is None` at harness.py:380.
Common situations: Agent crashed or was killed mid-stream before emitting the final metadata; a binary version that omits the terminal receipt feature; output piping truncating the last lines; running an older Codewhale build against the newer harness.
Related errors
- Codewhale emitted more than one terminal metadata receipt
- Codewhale metadata event was not a terminal receipt
- Codewhale stream-json did not end with exactly one done…
- Codewhale terminal metadata did not immediately precede done
- Codewhale terminal receipt omitted a valid
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/24a430a009937910.
Report an issue: GitHub.
Appendix: source
Thrown at integrations/verifiers-codewhale/codewhale_harness/harness.py:380
if event.get("schema") != STREAM_SCHEMA or event.get(
"schema_version"
) != STREAM_SCHEMA_VERSION:
raise RuntimeError("Codewhale stream-json schema did not match v0.9.1")
event_type = event.get("type")
if event_type not in _EVENT_TYPES:
raise RuntimeError("Codewhale stream-json contained an unknown event type")
counts[event_type] += 1
ordered_types.append(event_type)
if event_type == "metadata":
if terminal is not None:
raise RuntimeError("Codewhale emitted more than one terminal metadata receipt")
meta = event.get("meta")
if not isinstance(meta, dict) or meta.get("receipt_kind") != "terminal":
raise RuntimeError("Codewhale metadata event was not a terminal receipt")
terminal = _bounded_terminal(meta)
if terminal is None:
raise RuntimeError("Codewhale stream-json omitted terminal metadata")
if counts["done"] != 1 or not ordered_types or ordered_types[-1] != "done":
raise RuntimeError("Codewhale stream-json did not end with exactly one done event")
if ordered_types[-2:-1] != ["metadata"]:
raise RuntimeError("Codewhale terminal metadata did not immediately precede done")
for field in ["binary_sha256", "prompt_sha256"]:
if not isinstance(terminal.get(field), str) or not _SHA256.fullmatch(
terminal[field]
):
raise RuntimeError(f"Codewhale terminal receipt omitted a valid {field}")
return {
"schema": STREAM_SCHEMA,
"schema_version": STREAM_SCHEMA_VERSION,
"events": dict(sorted(counts.items())),
"terminal": terminal,
}
View on GitHub (pinned to 433685b202)