Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
When a session is compacted, the LLM generates a structured summary of the conversation. However, the user has no way to provide per-compaction guidance — e.g., what to prioritize in the summary, what information is no longer relevant, or what the next work focus should be.
The existing experimental.session.compacting plugin hook can inject context into the compaction prompt, but:
- It only receives
{ sessionID } — no per-invocation dynamic input
- The injected content is static (determined by plugin code), not changeable per compaction
Additionally, the recent conversation that the user might use to convey such guidance is often excluded from the compaction scope (it falls into the "recent" portion that is preserved verbatim), so the compaction LLM never sees it.
Proposal
Allow the user to pass an optional instruction string when triggering a compaction, which gets appended to the compaction LLM prompt.
Suggested changes
-
API layer — Add instruction?: string to SummarizePayload (packages/opencode/src/server/routes/instance/httpapi/groups/session.ts)
-
Handler — Pass instruction through compactSvc.create() → compaction.process() (packages/opencode/src/session/compaction.ts)
-
Compaction prompt — Append the user instruction to the summary prompt in processCompaction:
if (input.instruction) {
nextPrompt += `\n\nAdditional user instruction for this compaction:\n${input.instruction}`
}
-
TUI — When the user triggers /compact (or c), show a DialogPrompt input box (already available at packages/tui/src/ui/dialog-prompt.tsx) with a placeholder like "Optional: guide the compaction (what to prioritize, what to drop)…". The user can type a one-liner or leave it empty and press Enter to proceed.
Why
- Per-compaction guidance is a common pattern in agent frameworks (e.g., Claude Code's /compact with optional instructions)
- The change is minimal — one field threaded through 4 layers, each just passing it along
- No breaking changes — instruction is optional; existing behavior is preserved when it's absent
Context
- Current compaction implementation: packages/opencode/src/session/compaction.ts (V1 path, actively used)
- V2 core compaction (packages/core/src/session/compaction.ts) does not yet support plugin hooks; this proposal should be considered for both paths
- DialogPrompt component already exists and is used by other commands (e.g., session rename, provider config)
Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
When a session is compacted, the LLM generates a structured summary of the conversation. However, the user has no way to provide per-compaction guidance — e.g., what to prioritize in the summary, what information is no longer relevant, or what the next work focus should be.
The existing
experimental.session.compactingplugin hook can inject context into the compaction prompt, but:{ sessionID }— no per-invocation dynamic inputAdditionally, the recent conversation that the user might use to convey such guidance is often excluded from the compaction scope (it falls into the "recent" portion that is preserved verbatim), so the compaction LLM never sees it.
Proposal
Allow the user to pass an optional
instructionstring when triggering a compaction, which gets appended to the compaction LLM prompt.Suggested changes
API layer — Add
instruction?: stringtoSummarizePayload(packages/opencode/src/server/routes/instance/httpapi/groups/session.ts)Handler — Pass
instructionthroughcompactSvc.create()→compaction.process()(packages/opencode/src/session/compaction.ts)Compaction prompt — Append the user instruction to the summary prompt in
processCompaction:TUI — When the user triggers /compact (or c), show a DialogPrompt input box (already available at packages/tui/src/ui/dialog-prompt.tsx) with a placeholder like "Optional: guide the compaction (what to prioritize, what to drop)…". The user can type a one-liner or leave it empty and press Enter to proceed.
Why
Context