opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[FEATURE]: Add a Limits section, current (was old) values and error -> fix lines to the compaction summary template

Open johnstonjay opened this issue 2 days ago • 2 comments

Feature hasn't been suggested before.

  • [X] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

#48058 trimmed the summary prompt because summaries got too long. This is not a request to make them longer again. It's three small additions to SUMMARY_TEMPLATE:

  1. A ## Limits section for thresholds, budgets, quotas, timeouts and other numbers the work depends on.
  2. A rule: when a value changed during the session, write the current value first as current (was old).
  3. One line per resolved error as error -> fix, so the next agent doesn't retry what already failed.

These come from a compaction prompt I benchmarked: one model (grok-4.7), 3 real agent sessions of 26-30K tokens, 16 recall questions each, 10 runs per arm per session. No compaction scored 14.17/16. My previous prompt scored 11.30 and the new one 12.47 at the same 2,000-token request (+1.17, 95% CI +0.55 to +1.87).

Most of that gain came from length. The new prompt makes the model write about 1.6x what it's asked for, and the old prompt, asked for the same output length, scored the same. At matched length the new structure got more exact values into the handoff (10.8 vs 9.9 of 16 answer keys) but no clear score gain. That's why I'm asking only for the pieces that cost a few lines, not the whole prompt.

#42574 and #49463 are about making the prompt configurable. This is about the default.

Prompt, method and numbers: https://github.com/johnstonjay/portable-ai-skills Plugin with the full prompt and an empty-handoff retry: https://github.com/johnstonjay/opencode-adr-context-handoff

johnstonjay avatar Nov 29 '26 13:11 johnstonjay

Thanks for the detailed write-up and for publishing the benchmark method and numbers.

To restate the request: you're asking for three small additions to the default compaction SUMMARY_TEMPLATE, not for longer summaries overall:

  1. a ## Limits section for thresholds, budgets, quotas and timeouts
  2. a rule to write changed values as current (was old)
  3. one error -> fix line per resolved error

For reference, the current template ends with an ## Important Context section ("facts the next agent cannot continue without and cannot easily find on its own"). Its rules already say to "Preserve exact file paths, symbols, commands, error strings, URLs, and identifiers", but nothing covers values that changed or pairs an error with its fix.

Related issues:

  • #48058: the PR that trimmed this prompt, with its own measurements of summary size and generation time
  • #42574: custom instructions when compacting
  • #49463: a configurable compaction prompt and keeping user messages verbatim

Maintainers will consider whether to change the default. Until then, your plugin already brings the full prompt to anyone who wants it.

opencodejr[bot] avatar Nov 29 '26 13:11 opencodejr[bot]

Update: v2.3.3 of the prompt adds a short writing guide at the end (what to record, what to skip, three weak/strong example lines). On 8 recorded sessions with frozen questions it raised Haiku 5.5 by 0.53 facts of 18 (95% CI 0.10 to 0.97, n=15 paired) and changed Fable, Opus and Sonnet by +0.12 (CI 0.00 to 0.24, n=45). The prompt grows by about 330 tokens and handoffs by about 3%, so the gain is mostly for smaller models.

The plugin is updated to v2.3.3 (0.3.0) and now also retries a handoff that just echoes the template's placeholder lines.

https://github.com/johnstonjay/portable-ai-skills https://github.com/johnstonjay/opencode-adr-context-handoff

johnstonjay avatar Nov 29 '26 22:11 johnstonjay