Skip to content

[FEATURE]: Add expanded hook events to the plugin system to enable more powerful plugin capabilities. #21075

Closed as not planned

Description

@reactive-end

Feature hasn't been suggested before.

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

Describe the enhancement you want to request

Problem

The current OpenCode plugin system lacks many useful hook events that would allow plugins to intercept and customize agent behavior at key points. This makes it difficult to build powerful plugins that can:

  • Monitor session lifecycle (start/end)
  • Intercept tool execution (modify arguments, log results)
  • React to agent stopping events
  • Handle permission requests
  • Participate in session compaction

Proposed Solution

Expand the hook events system with new lifecycle hooks:

  • session.start / session.end - Session lifecycle
  • stop - Agent stop event
  • preToolUse / postToolUse - Tool execution interception
  • permission.request - Permission request event
  • preCompact / postCompact - Session compaction events
    All hooks include functional triggers in the codebase.

Files Changed

  • packages/plugin/src/index.ts - Hook type definitions
  • packages/opencode/src/session/index.ts - session.start/end triggers
  • packages/opencode/src/session/processor.ts - stop trigger
  • packages/opencode/src/session/prompt.ts - preToolUse/postToolUse triggers
  • packages/opencode/src/session/compaction.ts - preCompact/postCompact triggers
  • packages/opencode/src/permission/index.ts - permission.request trigger

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Apr 5, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 5, 2026
  3. github-actions commented on Apr 5, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature request titles must start with [FEATURE]: — please rename to: [FEATURE]: Add expanded hook events to the plugin system to enable more powerful plugin capabilities

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    This request appears to bundle several hooks that have already been individually requested. Please review the above issues and consider whether this should be closed in favor of the existing ones (or link to them).

    If you believe this was flagged incorrectly, please let a maintainer know.

  4. changed the title [-]Add expanded hook events to the plugin system to enable more powerful plugin capabilities.[/-] [+][Add expanded hook events to the plugin system to enable more powerful plugin capabilities.[/+] on Apr 5, 2026
  5. changed the title [-][Add expanded hook events to the plugin system to enable more powerful plugin capabilities.[/-] [+][FEAUTURE]: Add expanded hook events to the plugin system to enable more powerful plugin capabilities.[/+] on Apr 5, 2026
  6. changed the title [-][FEAUTURE]: Add expanded hook events to the plugin system to enable more powerful plugin capabilities.[/-] [+][FEATURE]: Add expanded hook events to the plugin system to enable more powerful plugin capabilities.[/+] on Apr 5, 2026
  7. github-actions commented on Apr 5, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! The title now correctly starts with [FEATURE]: and the issue meets our contributing guidelines. We appreciate the detailed proposal.

  8. xbjpku commented on Apr 22, 2026

    @xbjpku

    This is partially addressed by #23650 — a minimal session.turn.completed event (+9 lines, 2 files). It enables post-turn plugins like ScarletWitch, a filesystem sandbox that shows a COW review dialog after each turn. Happy to adjust based on feedback.

  9. assigned and unassigned on Apr 26, 2026
  10. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  11. github-actions commented on Jul 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions