opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Chat messages transform hook

Open jorgenwh opened this issue 1 month ago • 5 comments

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      |
                     |-----------------|

jorgenwh avatar Dec 07 '25 17:12 jorgenwh

/review

rekram1-node avatar Dec 07 '25 19:12 rekram1-node

/review

rekram1-node avatar Dec 08 '25 01:12 rekram1-node

lgtm

github-actions[bot] avatar Dec 08 '25 01:12 github-actions[bot]

/review

rekram1-node avatar Dec 11 '25 02:12 rekram1-node

lgtm

github-actions[bot] avatar Dec 11 '25 02:12 github-actions[bot]