OpenCode compaction keeps a summary beside recent conversation
Answer: OpenCode summarizes the conversation near the context limit and retains recent conversation beside the summary. Compaction is lossy.
OpenCode settings
Automatic compaction is enabled by default. keep.tokens controls how much recent conversation remains beside the summary; its default is 15000. Larger values preserve more detail but leave less room for new work.
buffer sets the share of the context window kept free, not the point at which compaction starts. Manual compaction also works when automatic compaction is disabled.
Gemini CLI comparison
Gemini CLI uses a different key. Its compressionThreshold setting is the fraction of context usage at which to trigger context compression. Its documented default is 0.5.
See also
- ao-compaction-gemini-cli-compress
- ao-mcp-opencode-config
- ao-compaction-memory-and-parallel
- ao-compaction
Claims
- id: C1 claim: OpenCode retains recent conversation beside its summary. source: S1 evidence: "beside the summary so exact recent details remain"
- id: C2 claim: OpenCode compaction is lossy. source: S1 evidence: "Compaction is lossy."
- id: C3 claim: Gemini compressionThreshold is a context usage fraction. source: S2 evidence: "The fraction of context usage at which to trigger context"
- id: C4 claim: Gemini documents a default of 0.5. source: S2 evidence: "Default:
0.5"
Sources
- [S1] Compaction (OpenCode docs). anomalyco/opencode (GitHub). https://github.com/anomalyco/opencode/blob/dev/services/site/src/docs/content/compaction.mdx . License: MIT. Accessed 2026-11-16.
- [S2] Gemini CLI configuration reference. google-gemini/gemini-cli (GitHub). https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md . License: Apache-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: anomalyco/opencode (GitHub), Compaction (OpenCode docs), MIT (https://raw.githubusercontent.com/anomalyco/opencode/dev/LICENSE). Copyright (c) 2025 opencode; google-gemini/gemini-cli (GitHub), Gemini CLI configuration reference, Apache-2.0 (https://raw.githubusercontent.com/google-gemini/gemini-cli/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: anomalyco/opencode (GitHub), Compaction (OpenCode docs), MIT (https://raw.githubusercontent.com/anomalyco/opencode/dev/LICENSE). Copyright (c) 2025 opencode; google-gemini/gemini-cli (GitHub), Gemini CLI configuration reference, Apache-2.0 (https://raw.githubusercontent.com/google-gemini/gemini-cli/main/LICENSE).
Cite this
iinventedlight. 2026. "OpenCode compaction keeps a summary beside recent conversation." iinventedlight Library, iil:note:d3nnxqmn, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-compaction-opencode-settings/. License: CC-BY-4.0.
@misc{iil_note_d3nnxqmn,
author = {{iinventedlight}},
title = {{OpenCode compaction keeps a summary beside recent conversation}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/ao-compaction-opencode-settings/},
note = {Permanent ID iil:note:d3nnxqmn. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- ao-compaction-opencode-settings.schema.json (schema; CC-BY-4.0)
- ao-compaction-opencode-settings.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-compaction-opencode-settings.md.