Skip to content

feat: Allow users to restrict workflow activation to specific agents - #259

Merged
mrsimpson merged 1 commit into
mainfrom
per-agent-activation
Apr 2, 2026
Merged

mrsimpson merged 1 commit into
mainfrom
per-agent-activation

Conversation

@mrsimpson

Copy link
Copy Markdown
Collaborator

… filtering

Intent

Allow users to restrict workflow activation to specific agents via the WORKFLOW_AGENTS environment variable. This prevents subagents (Tasks) from being interrupted by workflow instructions when they are not expected to follow the workflow.

Major changes

opencode-plugin

  • New WORKFLOW_AGENTS env var: comma-separated list of agent names (e.g., 'general,architect')
  • If unset (default), workflows are active for all agents (backward compatible)
  • If set, only agents in the list can use workflows
  • Agent filter evaluated on every chat.message hook
  • Tools throw clear error if agent not in whitelist: 'Workflows are not enabled for this agent'
  • Removed WORKFLOW=off global toggle (no longer needed with per-agent filtering)
  • Removed /workflow on|off command (YAGNI)

opencode-tui-plugin

  • Parse and respect WORKFLOW_AGENTS environment variable
  • Widget visibility derived from agent whitelist + current agent
  • Automatically hide/show widget on agent switches (reactive, no session state)
  • If agent not in filter, widget returns null (no DOM footprint)

Tests

  • Updated test suite to validate agent filtering instead of global on/off toggle
  • All 53 tests passing
  • New tests: agent not in filter throws error, agent in filter works, handles whitespace

Documentation

  • Updated opencode-plugin README with Configuration section
  • Updated TUI plugin README with agent-based visibility explanation
  • Removed .opencode/commands/workflow.md (command no longer exists)

Side effects

  • Backward compatible: workflows default to all agents when WORKFLOW_AGENTS is unset
  • Simpler codebase: removed all session-state caching for per-session toggles
  • Cleaner semantics: agent filter is now the single source of truth
  • Better UX: users get clear error messages instead of silent failures

… filtering

## Intent

Allow users to restrict workflow activation to specific agents via the WORKFLOW_AGENTS
environment variable. This prevents subagents (Tasks) from being interrupted by workflow
instructions when they are not expected to follow the workflow.

## Major changes

### opencode-plugin
- New WORKFLOW_AGENTS env var: comma-separated list of agent names (e.g., 'general,architect')
- If unset (default), workflows are active for all agents (backward compatible)
- If set, only agents in the list can use workflows
- Agent filter evaluated on every chat.message hook
- Tools throw clear error if agent not in whitelist: 'Workflows are not enabled for this agent'
- Removed WORKFLOW=off global toggle (no longer needed with per-agent filtering)
- Removed /workflow on|off command (YAGNI)

### opencode-tui-plugin
- Parse and respect WORKFLOW_AGENTS environment variable
- Widget visibility derived from agent whitelist + current agent
- Automatically hide/show widget on agent switches (reactive, no session state)
- If agent not in filter, widget returns null (no DOM footprint)

### Tests
- Updated test suite to validate agent filtering instead of global on/off toggle
- All 53 tests passing
- New tests: agent not in filter throws error, agent in filter works, handles whitespace

### Documentation
- Updated opencode-plugin README with Configuration section
- Updated TUI plugin README with agent-based visibility explanation
- Removed .opencode/commands/workflow.md (command no longer exists)

## Side effects

- Backward compatible: workflows default to all agents when WORKFLOW_AGENTS is unset
- Simpler codebase: removed all session-state caching for per-session toggles
- Cleaner semantics: agent filter is now the single source of truth
- Better UX: users get clear error messages instead of silent failures

Co-authored-by: udondan <udondan@users.noreply.github.com>
@mrsimpson

Copy link
Copy Markdown
Collaborator Author

superseeds #257

@mrsimpson
mrsimpson merged commit dd0fdf5 into main Apr 2, 2026
3 checks passed
@mrsimpson
mrsimpson deleted the per-agent-activation branch April 2, 2026 22:26
@mrsimpson

mrsimpson commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator Author

thanks for all the proposals, @udondan . That made it easier to find a (simpler) solution. YAGNI /workflow. Made you co-author ;)

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.

1 participant