Comparing main...fix/opencode-plugin-compact-loses-agent · codemcp/workflows · GitHub
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: codemcp/workflows
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: codemcp/workflows
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fix/opencode-plugin-compact-loses-agent
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on May 7, 2026

  1. fix: restore correct agent context after implicit compaction in proce…

    …ed_to_phase
    
    ## High level changes
    
    - `plugin.ts`: Added `lastKnownAgent` variable that caches the last enabled agent name seen in `chat.message`
    - `plugin.ts`: Post-compaction `promptAsync` now passes `agent: lastKnownAgent` in the request body so the continue message runs under the original workflow agent
    - `plugin.ts`: Added `postCompactionAutoResume` flag set on `session.compacted` to bypass the agent filter for OpenCode's own auto-continue message
    - `plugin.ts`: `chat.message` hook checks `bypassAgentFilter` before the `isAgentEnabled` guard so phase instructions are injected instead of a suppression/no-workflow notice
    
    ## Motivation
    
    After `proceed_to_phase` triggers implicit compaction, OpenCode resumes the session using its default agent (e.g. `build`) rather than the original workflow agent. This caused two problems:
    1. OpenCode's built-in auto-continue `chat.message` arrived with agent `build`, hit the `WORKFLOW_AGENTS` filter, and injected "No Active Workflow Detected" instead of phase instructions.
    2. The plugin's own follow-up `promptAsync` (sent on `session.idle`) also omitted the agent field, so it too ran under the wrong agent, losing system prompt and tool access.
    
    ## Details
    
    - `lastKnownAgent` is only updated when `isAgentEnabled` is true, ensuring a subagent name (e.g. `general`, `explore`) never overwrites the cached workflow agent.
    - `postCompactionAutoResume` is set to `true` on `session.compacted` and consumed (set back to `false`) by the very next `chat.message` invocation. This is a one-shot bypass: it covers exactly OpenCode's implicit auto-continue turn and nothing more.
    - The `promptAsync` body now spreads `{ agent: lastKnownAgent }` when a cached agent is available. `PromptInput.agent` is an optional string field in the OpenCode API, so this is a safe additive change with no effect when `lastKnownAgent` is `null`.
    mrsimpson committed May 7, 2026
    Configuration menu
    Copy the full SHA
    e27c7d6 View commit details
    Browse the repository at this point in the history
Loading