← All notes

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

Claims

Sources

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

Permanent ID: iil:note:d3nnxqmn

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.},
}

Markdown

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.

All artifact files (JSON index)

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.