Skip to content

plugin: the agent-output readers crash on a JSON line that is not an object #182

Closed

Description

@rahul05ranjan

What happens

Five readers of agent CLI output parse each line with json.loads and then call .get on the result, without the isinstance(ev, dict) check — the same gap #150 closed for the trace readers (and #181 for the cursor pair):

  • plugin/probe.py run_session — Copilot -p --output-format json stdout: ev.get("type")
  • plugin/probe.py inspect_session — Copilot's own events.jsonl: json.loads(line).get("data") (this one also has no except ValueError, so a partially-written or corrupt line containing "hook.end" crashes before .get is even reached)
  • plugin/sidecall.py codex_call — codex exec --json stdout: ev.get("item")
  • plugin/sidecall.py copilot_call — Copilot -p stdout: ev.get("type")
  • plugin/toolcheck.py _init_tools — claude -p --output-format stream-json stdout: ev.get("type")

A line that is valid JSON but not an object (null, 42, "text", [1, 2]) — or, for inspect_session, any line with the "hook.end" prefilter that does not parse — raises and kills the whole probe / side call / tool check, instead of skipping the one line.

These are external-process streams, same exposure as the transcripts #150 hardened: anything the CLI or a tool it spawns writes to inherited stdout lands line-shaped in these loops.

Repro

>>> # sidecall.codex_call with a stubbed runner whose stdout is:
"null\n{\"type\":\"item.completed\",\"item\":{\"type\":\"agent_message\",\"text\":\"hi\"}}\n"
AttributeError: 'NoneType' object has no attribute 'get'

Fix

The same one-line isinstance(ev, dict) guard after json.loads in the four loops, plus the ValueError catch in inspect_session. I have it with regression tests ready and will open the PR.

Activity

  1. added 2 commits that reference this issue on Nov 9, 2026
    859bd01
    dc66f58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions