Surface new Claude Code JSONL event types (cache misses, queue ops, mode/tool/skill/MCP deltas)#20
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ──— surfacesassistant.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-levelqueue-operationevents 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_listingdeltas.Suppression rules:
skill_listing.isInitial=true(session-start bulk dump) — dropped.*_deltawith empty added/removed/readded — dropped.queue-operationenqueues whose content is a<task-notification>(TaskStop result re-injection) — dropped; not a user-typed prompt.Implementation:
TypeCacheMissandTypeSessionEvent(umbrella marker) types inparser.AssistantMessage.Diagnosticsadded; emits an extraTypeCacheMissitem alongside the assistant message that bust the cache.parseAttachmentextended for the four new attachment subtypes.ParseLineextended for top-levelqueue-operation.TypeCompactMarker/TypePRLinkpattern.oneLineSnippet) keeps long queued prompts from breaking the divider layout.Deferred:
permission-modechange 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 cleanqueued:markers appearskill_listingmarker🤖 Generated with Claude Code