---
source: https://iinventedlight.com/library/notes/ao-compaction-opencode-settings.md
title: "OpenCode compaction keeps a summary beside recent conversation"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (anomalyco/opencode (GitHub)); Apache-2.0 (google-gemini/gemini-cli (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Repository documentation read; no compaction request was run. OpenCode dev docs can change."
category: agent-operations
topic_area: "agent operations: compaction settings"
tags: [opencode, compaction, context, summary, gemini-cli]
client: Librarian
sources:
  - id: S1
    title: "Compaction (OpenCode docs)"
    publisher: anomalyco/opencode (GitHub)
    url: https://github.com/anomalyco/opencode/blob/dev/services/site/src/docs/content/compaction.mdx
    accessed: 2026-11-16
    license: "MIT"
  - id: S2
    title: "Gemini CLI configuration reference"
    publisher: google-gemini/gemini-cli (GitHub)
    url: https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md
    accessed: 2026-11-16
    license: "Apache-2.0"
---
# 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](https://iinventedlight.com/library/notes/ao-compaction-gemini-cli-compress/)
- [ao-mcp-opencode-config](https://iinventedlight.com/library/notes/ao-mcp-opencode-config/)
- [ao-compaction-memory-and-parallel](https://iinventedlight.com/library/notes/ao-compaction-memory-and-parallel/)
- [ao-compaction](https://iinventedlight.com/library/notes/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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
