Skip to content

[FEATURE]: Expose the ability to modify the chat messages thread via a plugin #7034

Closed

Description

@NikhilVerma

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

Agents can often go down long paths and end up with either fruitful or bad results. We should allow a plugin or a tool to say "Ok I have gone down this path, and here is what I learnt, now we don't need to go down there again. Here be dragons" and effectively say

"Go back to this message in the chat history, send a message X back in time, and resume the chat from there"

This will allow for a lot longer running agents, who can be encouraged to do trial and error.

I think a tool might be the best here, but plugins can unlock interesting opportunities as well.

Existing feature request

I searched for time travel and found this - #4659 but it's not what I mean

Activity

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

    @github-actions
    Contributor

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

    Feel free to ignore if none of these address your specific case.

  3. Wuchv commented on Jan 23, 2026

    @Wuchv

    I have the same requirement. my case is that a large model needs to understand an image based on a URL.

    The prompt is as follows:
    https://xxxxx/xxx.png please describe this image.

    Opencode interprets the request to the large model as a text:

    "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "https://xxxxx/xxx.png please describe this image",
            }
          ]

    but the format required for large models is as follows:

        "messages": [
            {
                "role": "user",
                "content":
                [
                    {
                        "type": "image_url",
                       "image_url": "https://xxxxx/xxx.png"
                    },
                    {
                        "type": "text",
                        "text": "please describe this image"
                    }
                ]
            }
        ]

    I need a hook that can modify messages before making a request to the large model.

  4. Wuchv commented on Jan 23, 2026

    @Wuchv

    I have the same requirement. my case is that a large model needs to understand an image based on a URL.

    The prompt is as follows: https://xxxxx/xxx.png please describe this image.

    Opencode interprets the request to the large model as a text:

    "messages": [
    {
    "role": "user",
    "content": [
    {
    "type": "text",
    "text": "https://xxxxx/xxx.png please describe this image",
    }
    ]
    but the format required for large models is as follows:

    "messages": [
        {
            "role": "user",
            "content":
            [
                {
                    "type": "image_url",
                   "image_url": "https://xxxxx/xxx.png"
                },
                {
                    "type": "text",
                    "text": "please describe this image"
                }
            ]
        }
    ]
    

    I need a hook that can modify messages before making a request to the large model.

    https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/session/prompt.ts#L594

    I looked at the code of OpenCode and found that it now supports modifying messages. Here is a demo:

    export const MessagePlugin: Plugin = async (
      input: PluginInput,
    ): Promise<Hooks> => {
      const client = input.client;
    
      return {
        'experimental.chat.messages.transform': async (hookInput, output) => {
          for (const message of output.messages) {
            if (message.info.role !== 'user')
              return;
    
            const newParts: Part[] = [];
    
            await client.app.log({
              body: {
                service: 'message-plugin',
                level: 'info',
                message: 'user message',
                extra: {
                  message,
                },
              },
            });
    
            for (const part of message.parts) {
              if (part.type === 'text') {
                // ...
                newParts.push(part);
            }
    
            if (newParts.length !== message.parts.length) {
              message.parts = newParts;
            }
          }
        },
      };
    };
  5. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 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

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions