Skip to content

[FEATURE] pre_chat.messages.transform hook for image-to-text stripping #25494

Closed as not planned

Description

@n1flh31mur

Verification

Problem

Plugins cannot strip or transform messages before they reach the LLM. When a user attaches an image, the LLM errors out with "this model does not support image input".

The existing hooks have limitations:

Proposed Solution

Add pre_chat.messages.transform — a hook that fires before the LLM, receiving the full messages array and allowing plugins to transform them:

"pre_chat.messages.transform"?: (
  input: {
    sessionID: string
    agent: string
    model: Model
    messages: { info: Message; parts: Part[] }[]
  },
  output: { messages: { info: Message; parts: Part[] }[] },
) => Promise<void>

Use Cases

  1. Image-to-text stripping: Scan for FilePart with image: true, call a Vision server (Qwen2.5-VL-3B), replace with TextPart containing the description
  2. Vision plugin integration: Transform messages on-the-fly so the LLM always receives text-only input
  3. Pre-inference modification: Any plugin that needs to modify messages before the LLM

Backward Compatibility

  • experimental.chat.messages.transform is non-functional (empty input). Marked @deprecated and replaced by this new hook
  • No breaking changes to existing hooks

Required Go Binary Change (separate PR)

The Go binary needs to:

  1. Register pre_chat.messages.transform hooks from the plugin registry
  2. Call them with the messages array before invoking the LLM
  3. Collect output.messages and pass the transformed array to the model

PR

SDK type changes: #25493

Activity

  1. github-actions commented on May 2, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature requests must have a title starting with [FEATURE]: (current title: "feat(plugin): add pre_chat.messages.transform hook for image stripping")
    • Feature requests must include the verification checkbox confirming the feature hasn't been suggested before

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. changed the title [-]feat(plugin): add pre_chat.messages.transform hook for image stripping[/-] [+][FEATURE] pre_chat.messages.transform hook for image-to-text stripping[/+] on May 2, 2026
  3. github-actions commented on May 2, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! Everything looks good now — the title, verification checkbox, and description all meet our contributing guidelines.

  4. github-actions commented on Jul 3, 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