Skip to content

fix(opencode): filter compaction events from jsonl output - #42316

Open
vladislav-miroshnikov wants to merge 1 commit into
anomalyco:devfrom
vladislav-miroshnikov:jsonl-compaction-filter
Open

fix(opencode): filter compaction events from jsonl output#42316
vladislav-miroshnikov wants to merge 1 commit into
anomalyco:devfrom
vladislav-miroshnikov:jsonl-compaction-filter

Conversation

@vladislav-miroshnikov

Copy link
Copy Markdown

Issue for this PR

Fixes #42238

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When auto-compaction occurs, opencode run --format json emits internal compaction output (summaries, step events, reasoning) as ordinary JSONL events. Consumers cannot distinguish these from user-visible assistant output.

The fix tracks compaction message IDs from message.updated events (where info.mode === "compaction") and skips all parts belonging to those messages. Synthetic continuation prompts are also filtered via part.synthetic.

How did you verify your code works?

All 13 existing run-process.test.ts tests pass with no regression. bun typecheck passes clean. The compactionMessages Set is populated from message.updated which fires before any message.part.updated for the same message (sequential publish in the same Effect fiber), so the filter is always in place before parts arrive.

A dedicated compaction test would require triggering real context overflow in the subprocess harness, which is complex with the mock LLM server. The fix was verified manually against the issue's reproduction steps.

Checklist

  • I have read the contributing guide
  • I have verified my code works on the target platform

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.

opencode run --format json emits auto-compaction internals as ordinary text events

1 participant