Skip to content

OpenCode: no explicit post-compaction re-injection of workflow bootstrap #68

Description

@cinvymoe

Summary

The OpenCode plugin (.opencode/plugins/spec-superflow.js) has no dedicated handling for OpenCode's context compaction. After compaction, recovery of the <EXTREMELY_IMPORTANT> bootstrap only happens as an accidental side effect of the experimental.chat.messages.transform dedup check — not by design.

Current behavior

The plugin registers two hooks:

  1. config — registers the skills directory.
  2. experimental.chat.messages.transform — prepends the bootstrap (GEMINI.md wrapped in <EXTREMELY_IMPORTANT>) to the first user message, guarded by a dedup check:
if (firstUser.parts.some(p => p.type === 'text' && p.text.includes('EXTREMELY_IMPORTANT'))) return;

After OpenCode compacts the session, the message history is replaced by a summary. The first "user" message (the compaction summary) no longer contains EXTREMELY_IMPORTANT, so the dedup check fails and the bootstrap is silently re-injected on the next message send.

Problems

  1. Timing: re-injection happens on the next outgoing message, not at compaction time — the first post-compaction model turn runs without the bootstrap context.
  2. Fragility: it depends on the compaction summary never containing the literal string EXTREMELY_IMPORTANT. If a future OpenCode version includes prior context in the summary, re-injection silently stops.
  3. Undocumented: a repo-wide search for compacting / compaction finds nothing — this behavior is an emergent side effect, not a tested contract.

Suggestion

Add an explicit experimental.session.compacting hook that appends the bootstrap to output.context, e.g.:

'experimental.session.compacting': async (_input, output) => {
  const bootstrap = getBootstrapContent();
  if (!bootstrap) return;
  output.context.push(bootstrap);
},

This guarantees the workflow bootstrap survives compaction deterministically, at the moment compaction happens.

Environment

  • spec-superflow version: current main (v0.10.0)
  • Platform: OpenCode

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions