Hmbown/CodeWhale · error · RuntimeError
Codewhale stream-json contained an unknown event type
Error message
Codewhale stream-json contained an unknown event type
What it means
After the schema envelope check, the harness requires event['type'] to be one of ten known types: content, tool_use, tool_result, sandbox_denied, workflow_event, session_capture, turn_usage, metadata, done, error. This error means the event carried an unrecognized type string, which usually indicates the binary and harness disagree on the event vocabulary.
Source
Thrown at integrations/verifiers-codewhale/codewhale_harness/harness.py:368
if not line.strip():
continue
try:
event = json.loads(line)
except json.JSONDecodeError as error:
raise RuntimeError(
f"Codewhale stream-json line {line_number} was not valid JSON"
) from error
if not isinstance(event, dict):
raise RuntimeError(
f"Codewhale stream-json line {line_number} was not an object"
)
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(View on GitHub (pinned to 8880682c63)
Solutions
- Capture stdout and list the distinct 'type' values; the failing one is not in {content, tool_use, tool_result, sandbox_denied, workflow_event, session_capture, turn_usage, metadata, done, error}.
- Revert to the pinned Codewhale version 0.9.1 via CodewhaleHarnessConfig.version so the vocabulary matches.
- If the new event type is legitimate, add it to _EVENT_TYPES in harness.py and update the harness contract tests in the same commit.
- If the type is noise from a wrapper, remove that emission or route it to stderr.
Example fix
# before: facade emits an unmapped type
{"schema": "codewhale.exec-stream", "schema_version": 1, "type": "thinking", ...}
# after: map it to a known type or teach the harness
# (a) producer side: fold it into an existing type
{"schema": "codewhale.exec-stream", "schema_version": 1, "type": "content", ...}
# (b) harness side: _EVENT_TYPES.add("thinking") Defensive patterns
Strategy: validation
Validate before calling
KNOWN_EVENT_TYPES = {
"content", "tool_use", "tool_result", "sandbox_denied",
"workflow_event", "session_capture", "turn_usage",
"metadata", "done", "error",
}
def types_are_known(stdout: str) -> bool:
return all(
json.loads(line).get("type") in KNOWN_EVENT_TYPES
for line in stdout.splitlines()
if line.strip()
) Type guard
def is_known_event(event: object) -> bool:
return isinstance(event, dict) and event.get("type") in KNOWN_EVENT_TYPES Prevention
- Upgrade harness and binary together so _EVENT_TYPES matches the producer's vocabulary.
- When adding a producer event type, extend _EVENT_TYPES in the same change with tests.
- Prefer mapping new signals onto existing types (content/error/workflow_event) before minting new ones.
When it happens
Trigger: A Codewhale build emits a new event type (e.g. a post-0.9.1 'thinking' or 'plan' event) that the harness's _EVENT_TYPES set does not include; or a facade writes a typo'd type like 'tool-use'. The stream is rejected even though the JSON and envelope were valid.
Common situations: Upgrading the Codewhale binary without updating the harness; using binary_path against a feature branch that added event types; hand-writing stream fixtures for tests with an invented type name.
Related errors
- Codewhale stream-json schema did not match v0.9.1
- Codewhale stream-json line {line_number} was not an object
- 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 even
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/33700f3b71058bc3.
Report an issue: GitHub.