Skip to content

fix(opencode): serialize orphaned compaction history - #40800

Merged
rekram1-node merged 2 commits into
devfrom
compact-summary-text
Aug 7, 2026
Merged

fix(opencode): serialize orphaned compaction history#40800
rekram1-node merged 2 commits into
devfrom
compact-summary-text

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • serialize all compaction history into readable labeled text inside one user message
  • preserve user, assistant, reasoning, tool-call, tool-result, error, and attachment context while truncating large tool output
  • cover normal and repeated compaction with a retained tool-call tail

Why

A split retained tail can begin with an assistant function call. On repeated compaction, the previous compaction scaffold is removed, leaving that function call first in the summarization request. Gemini rejects this ordering because the function call has no preceding user or function-response turn.

Compaction now follows the current V2 approach: history is rendered as textual records such as [User], [Assistant tool call], and [Tool result], then sent as a single user summarization request. This avoids provider-specific conversation-order constraints without serializing the complete message objects as JSON.

Test plan

  • bun test test/session/compaction.test.ts (53 passed, 1 skipped)
  • bun x prettier --check src/session/compaction.ts test/session/compaction.test.ts

Requested by: @rekram1-node (Aiden Cline via Slack)

@rekram1-node
rekram1-node merged commit b7f9363 into dev Aug 7, 2026
11 checks passed
@rekram1-node
rekram1-node deleted the compact-summary-text branch August 7, 2026 02:11
HQ123-BOOP pushed a commit to HQ123-BOOP/LibreCode that referenced this pull request Aug 7, 2026
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
charlesverge pushed a commit to charlesverge/opencode that referenced this pull request Aug 11, 2026
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant