Skip to content

Surface new Claude Code JSONL event types (cache misses, queue ops, mode/tool/skill/MCP deltas)#20

Merged
phiat merged 1 commit into
mainfrom
feat/new-jsonl-event-types
May 23, 2026
Merged

Surface new Claude Code JSONL event types (cache misses, queue ops, mode/tool/skill/MCP deltas)#20
phiat merged 1 commit into
mainfrom
feat/new-jsonl-event-types

Conversation

@phiat
Copy link
Copy Markdown
Owner

@phiat phiat commented May 23, 2026

Summary

Claude Code 2.1.150+ emits several JSONL event types we silently dropped. This PR adds parser + renderer coverage for the high-signal ones.

New stream markers:

  • ── cache miss: tools_changed, +51k tokens ── — surfaces assistant.diagnostics.cache_miss_reason. Directly explains why per-agent context% spikes unexpectedly (e.g. ToolSearch loading a new tool busts the prompt cache, forcing tens of thousands of tokens to be re-sent).
  • ── queued: <prompt> ── / ── dequeued ── — top-level queue-operation events when the user types a follow-up prompt while CC is still working.
  • ── plan mode exit ──, ── auto mode ── — attachment subtypes for mode transitions.
  • ── tools: +28 ──, ── MCP: +1 ──, ── skills: 50 total ──deferred_tools_delta / mcp_instructions_delta / skill_listing deltas.

Suppression rules:

  • skill_listing.isInitial=true (session-start bulk dump) — dropped.
  • *_delta with empty added/removed/readded — dropped.
  • queue-operation enqueues whose content is a <task-notification> (TaskStop result re-injection) — dropped; not a user-typed prompt.

Implementation:

  • New TypeCacheMiss and TypeSessionEvent (umbrella marker) types in parser.
  • AssistantMessage.Diagnostics added; emits an extra TypeCacheMiss item alongside the assistant message that bust the cache.
  • parseAttachment extended for the four new attachment subtypes.
  • ParseLine extended for top-level queue-operation.
  • Renderer adds two early-return branches mirroring the existing TypeCompactMarker / TypePRLink pattern.
  • One-line content snippet helper (oneLineSnippet) keeps long queued prompts from breaking the divider layout.

Deferred: permission-mode change detection. CC re-emits this on every prompt, so without per-session dedup it floods the stream. Will land as a separate change since it needs state outside the stateless parser.

Tests: 13 new parser tests covering each handler + each suppression case. Smoke-tested against real 2.1.150 sessions — produces 19–20 session-event markers and 3 cache-miss markers per ~1000-line session, proportionate to actual user activity.

Test plan

  • go build ./... && go test ./... && go vet ./... all clean
  • Run claude-esp against a fresh CC 2.1.150 session and observe cache-miss markers appear after a ToolSearch / MCP load
  • Run against a session with user-queued follow-up prompts; verify queued: markers appear
  • Verify session-start does NOT show a giant skill_listing marker
  • Verify a long queued paragraph renders as a single-line ellipsised marker

🤖 Generated with Claude Code

Claude Code 2.1.150+ emits several event types we silently dropped.
This adds parser + renderer coverage for the high-signal ones:

- TypeCacheMiss: prompt-cache invalidation (assistant.diagnostics
  .cache_miss_reason). Renders as "── cache miss: tools_changed,
  +51k tokens ──". Directly explains why per-agent context% jumps
  unexpectedly (e.g. ToolSearch loading a tool busts the cache).

- TypeSessionEvent (umbrella marker): queue-operation enqueue/remove,
  attachment subtypes plan_mode_exit, auto_mode, deferred_tools_delta,
  mcp_instructions_delta, skill_listing. Each renders as a single muted
  divider line.

Suppression rules:
- skill_listing.isInitial=true is the session-start bulk dump — dropped.
- *_delta with empty added/removed/readded lists — dropped.
- queue-operation enqueue with <task-notification> content (TaskStop
  result re-injection) — dropped; not a user-typed prompt.

Permission-mode dedup deferred to a follow-up issue — needs per-session
state since CC re-emits it on every prompt.

Tests: 13 new parser tests covering each handler + suppression case.
Smoke-tested against real 2.1.150 sessions in ~/.claude/projects/.

Closes claude-esp-ska, claude-esp-g8q, claude-esp-aax.
Follow-up: claude-esp-9ij (permission-mode change detection).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@phiat phiat merged commit 86aecb0 into main May 23, 2026
2 checks passed
@phiat phiat deleted the feat/new-jsonl-event-types branch May 23, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant