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

Đang mở
#182 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@rahul05ranjan đang làm issue này rồi.

Từ ngày 9/11/2026.

  • #183 của @rahul05ranjan — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
5.6k
Fork
344
Merge trung bình
14 giờ 41 phút
Pull request đã merge (30 ngày)
54

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/TokenEconomizer

Tất cả issue của microsoft/TokenEconomizer

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.