Skip to content

feat(opencode-plugin): make auto-compaction configurable via WORKFLOW_AUTO_COMPACT - #261

Merged
mrsimpson merged 8 commits into
codemcp:mainfrom
udondan:feat/workflow-auto-compact-env-var
Apr 16, 2026
Merged

mrsimpson merged 8 commits into
codemcp:mainfrom
udondan:feat/workflow-auto-compact-env-var

Conversation

@udondan

@udondan udondan commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Gates the phase-transition compaction introduced in 0ad4aa0 behind a WORKFLOW_AUTO_COMPACT env var
  • When WORKFLOW_AUTO_COMPACT=false, compaction is skipped and a debug log is emitted instead
  • Default behaviour is unchanged (compaction runs on every successful phase transition)

Test plan

  • Existing e2e test triggers compaction after a successful phase transition still passes (default on)
  • New e2e test does not trigger compaction when WORKFLOW_AUTO_COMPACT=false verifies opt-out
  • Existing test does not trigger compaction when transition fails unaffected

…_AUTO_COMPACT

Add WORKFLOW_AUTO_COMPACT env var to control whether session compaction
is triggered on phase transition. Defaults to enabled; set to 'false' to
disable. Adds a corresponding e2e test case.
Copilot AI review requested due to automatic review settings April 16, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-out switch for the opencode-plugin’s automatic “compaction” (session summarize) that runs after successful phase transitions, controlled via WORKFLOW_AUTO_COMPACT.

Changes:

  • Gate client.session.summarize() in proceed_to_phase behind WORKFLOW_AUTO_COMPACT (default remains enabled).
  • Emit a debug log when compaction is skipped due to WORKFLOW_AUTO_COMPACT=false.
  • Add an E2E test verifying compaction is not triggered when the env var opt-out is set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/opencode-plugin/src/tool-handlers/proceed-to-phase.ts Adds env-var gating around post-transition compaction and logs skip behavior.
packages/opencode-plugin/test/e2e/plugin.test.ts Adds E2E coverage for opt-out behavior (WORKFLOW_AUTO_COMPACT=false).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode-plugin/test/e2e/plugin.test.ts Outdated
Comment thread packages/opencode-plugin/src/tool-handlers/proceed-to-phase.ts Outdated
udondan added 2 commits April 16, 2026 16:48
- Normalize env var with trim/toLowerCase before comparison
- Restore original env var value in test finally block instead of unconditional delete

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode-plugin/test/e2e/plugin.test.ts Outdated
Comment thread packages/opencode-plugin/test/e2e/plugin.test.ts Outdated
Comment thread packages/opencode-plugin/src/tool-handlers/proceed-to-phase.ts
- Add sessionID to skip-compaction debug log for easier troubleshooting
- Ensure WORKFLOW_AUTO_COMPACT is cleared in global beforeEach alongside WORKFLOW_AGENTS so compaction tests are deterministic in any environment
- Assert proceed_to_phase result contains 'plan' in opt-out test to confirm the transition succeeded (not just that summarize was skipped due to an error)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode-plugin/test/e2e/plugin.test.ts Outdated
Comment thread packages/opencode-plugin/src/tool-handlers/proceed-to-phase.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/opencode-plugin/src/tool-handlers/proceed-to-phase.ts Outdated
Comment thread packages/opencode-plugin/test/e2e/plugin.test.ts Outdated
udondan and others added 2 commits April 16, 2026 17:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mrsimpson
mrsimpson merged commit 8896d25 into codemcp:main Apr 16, 2026
6 of 7 checks passed
@udondan
udondan deleted the feat/workflow-auto-compact-env-var branch April 16, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants