Skip to content

[FEATURE]: Add messageID to tool.execute.before/after hook payloads #15933

Closed as not planned

Description

@chaomao

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

Description

The tool.execute.before and tool.execute.after plugin hooks currently receive { tool, sessionID, callID } in their input, but do not include messageID.

This makes it impossible for plugin authors to correlate a tool call back to the specific assistant message that triggered it. The messageID is already available in the ToolContext at every call site in packages/opencode/src/session/prompt.ts, so exposing it through the hook payload is straightforward.

Use case

When building plugins that log, audit, or post-process tool executions, you often need to group tool calls by the assistant message that initiated them. Without messageID in the hook payload, there's no way to do this — callID is unique per tool call and sessionID is too broad.

Proposed solution

Add messageID: string to the input type of both hooks in packages/plugin/src/index.ts:

  • tool.execute.before: { tool: string; sessionID: string; callID: string } → { tool: string; sessionID: string; callID: string; messageID: string }

  • tool.execute.after: same change

Then pass messageID at the three trigger sites in packages/opencode/src/session/prompt.ts (built-in tools, MCP tools, and the task tool).

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Mar 4, 2026
  2. github-actions commented on Mar 4, 2026

    @github-actions
    Contributor

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

    These are closely related requests to extend the same hook payloads with additional context. It may be worth coordinating or consolidating these into a single broader enhancement.

  3. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 4, 2026
  4. chaomao commented on Mar 4, 2026

    @chaomao
    Author

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

    These are closely related requests to extend the same hook payloads with additional context. It may be worth coordinating or consolidating these into a single broader enhancement.

    thanks for the reply. I did review suggested issue but they are not perfect cover my issue/pr. so I still think my issue/pr is needed :)

  5. assigned and unassigned on Apr 26, 2026
  6. 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
  7. github-actions commented on Jul 5, 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