[PR #5207] add experimental.chat.messages.transform hook #11292

Closed
opened 2026-02-16 18:16:06 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5207

State: closed
Merged: Yes


Add a chat messages transform hook to allow plugins to alter chat messages.

We expose the MessageV2.WithParts through the new hook, but give deep copies of the chat history to avoid plugins altering the original messages

Previously, the chain would look something like this:

MessageV2.WithParts -> ModelMessage -> ...

Now, with the new changes:

MessageV2.WithParts -> MessageV2.WithParts (in-memory copy) -> ModelMessage -> ...
                              |
                   chat.messages.transform
                              |
                     |-----------------|
                     |     Plugin      |
                     |-----------------|
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5207 **State:** closed **Merged:** Yes --- Add a chat messages transform hook to allow plugins to alter chat messages. We expose the MessageV2.WithParts through the new hook, but give deep copies of the chat history to avoid plugins altering the original messages Previously, the chain would look something like this: ``` MessageV2.WithParts -> ModelMessage -> ... ``` Now, with the new changes: ``` MessageV2.WithParts -> MessageV2.WithParts (in-memory copy) -> ModelMessage -> ... | chat.messages.transform | |-----------------| | Plugin | |-----------------| ```
yindo added the pull-request label 2026-02-16 18:16:06 -05:00
yindo closed this issue 2026-02-16 18:16:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11292