feat(plugin): add pre_chat.messages.transform hook for image stripping#25493
Open
n1flh31mur wants to merge 2 commits intoanomalyco:devfrom
Open
feat(plugin): add pre_chat.messages.transform hook for image stripping#25493n1flh31mur wants to merge 2 commits intoanomalyco:devfrom
n1flh31mur wants to merge 2 commits intoanomalyco:devfrom
Conversation
Add a new hook type that fires BEFORE the LLM is invoked, allowing plugins to inspect and transform the messages array. This enables: - Image-to-text stripping (replace FilePart with text descriptions) - Vision plugin integration (add Qwen2.5-VL-3B descriptions) - Pre-inference message modification The existing experimental.chat.messages.transform had empty input and was non-functional. Mark it as deprecated. Changes: - Add pre_chat.messages.transform hook with full messages input - Mark experimental.chat.messages.transform as @deprecated - Document the hook's purpose and usage pattern
1 task
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
…vocation Add the runtime dispatch of pre_chat.messages.transform in the main prompt processing pipeline. This fires after system prompt assembly but before tool resolution and the LLM API call. Also fixes the existing experimental.chat.messages.transform call to pass proper input context (sessionID, agent, model, messages) instead of an empty object. This is the companion to PR anomalyco#25493 which adds the SDK type definitions. Without this dispatch, the hook type exists but is never called at runtime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #25494
Type of change
What does this PR do?
The SDK defines a
pre_chat.messages.transformhook type that fires before the LLM is invoked, allowing plugins to inspect and transform the messages array. Currently this type is declared in the SDK but the Go binary does not dispatch it — the PR adds the type so plugins can register a handler.The hook receives the full messages array (sessionID, agent, model, messages with parts) and lets plugins return a transformed array. A plugin can scan for
FilePartobjects withimage: true, call a Vision server to get a text description, and replace each image part with aTextPartcontaining that description.This enables vision/image support without modifying the Go binary — once the binary starts dispatching this hook, plugins like
noctem-swarm-visioncan strip images on-the-fly.The existing
experimental.chat.messages.transformhook is marked @deprecated because it has empty input (input: {}) and never receives messages.How did you verify your code works?
chat.paramsandtool.execute.beforeexperimental.chat.messages.transformis syntactically validScreenshots / recordings
N/A — type-only change.
Checklist