Skip to content

feat(plugin): add messageID to tool.execute.before/after hooks#15831

Open
chaomao wants to merge 3 commits intoanomalyco:devfrom
chaomao:feat/tool-execute-message-id
Open

feat(plugin): add messageID to tool.execute.before/after hooks#15831
chaomao wants to merge 3 commits intoanomalyco:devfrom
chaomao:feat/tool-execute-message-id

Conversation

@chaomao
Copy link
Copy Markdown

@chaomao chaomao commented Mar 3, 2026

Tool execution hooks now include the messageID so plugin authors can correlate tool calls back to the assistant message that triggered them.

Issue for this PR

Close #15933

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • tool.execute.before and tool.execute.after hook payloads were missing messageID, making it impossible for plugin authors to correlate a tool call back to the assistant message that triggered it
  • Added messageID: string to the input of both hooks in packages/plugin/src/index.ts
  • Updated all three trigger sites in packages/opencode/src/session/prompt.ts: built-in tools, MCP tools, and the task tool

How did you verify your code works?

  • bun run --cwd packages/opencode typecheck passes with no errors
  • messageID is already present in the local Tool.Context at every trigger site (input.processor.message.id for built-in/MCP tools, assistantMessage.id for the task tool) — this just threads it through to the plugin payload

Screenshots / recordings

below is the screenshot of tool.execute.before hooks show logs.
Screenshot 2026-03-03 at 20 10 49

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

chaomao and others added 2 commits March 3, 2026 18:30
Tool execution hooks now include the messageID so plugin authors can
correlate tool calls back to the assistant message that triggered them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chaomao
Copy link
Copy Markdown
Author

chaomao commented Mar 3, 2026

@adamdotdevin please review

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.

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

1 participant