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

オープン
#182 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@rahul05ranjan がすでに取り組んでいます。

2026年11月9日 から。

  • #183 @rahul05ranjan による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

Read plugin/probe.py (run_session and inspect_session), plugin/sidecall.py (codex_call and copilot_call), and plugin/toolcheck.py (_init_tools); the report names each affected reader and the failure case. Check the regression tests mentioned in the linked pull request, then confirm malformed or non-object JSON lines are skipped while valid events still work. Pull request #183 is already open.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
5.6k
フォーク
344
平均マージ
14時間 41分
マージ済み PR(30日)
54

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/TokenEconomizer のほかの issue

microsoft/TokenEconomizer の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。