feat: add transform_llm_output plugin hook#20813
Closed
JezzaHehn wants to merge 1 commit into
Closed
Conversation
Enables plugins to transform LLM output text after generation, useful for vocabulary/personality transformation without burning inference tokens. Follows same pattern as transform_tool_result and transform_terminal_output: - First non-empty string result wins - Fail-open: exceptions logged as warnings, agent continues - Signature: (response_text, session_id, model, platform)
Contributor
Author
|
Please note the "Contributor Attribution Check" pipeline was due to my not having added my agent's email address to my GitHub account, which is now fixed The other failed pipeline, I'm not sure if that has anything to do with this change Big thanks as always to the core Nous team!!!! 💚 Screenshot of the silly Spongebob flavored version in action: Other more useful cases might be name substitution or profanity cleaning. |
Contributor
Author
|
Additional small note, the following quicktip is adjacent to this PR and might could be updated if/when the PR goes through cleanly ✦ Tip: Plugin hooks include pre/post_tool_call, pre/post_llm_call, and transform_terminal_output for output canonicalization. |
Contributor
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.

Summary
Adds a new plugin hook
transform_llm_outputthat allows plugins to transform the LLM's output text before it's returned to the user.Motivation
Personalized vocabulary transformation previously required either lots of personality flavor text in the SOUL, a skill that burned inference tokens on every response, or similar systems which burn tokens unnecessarily. A native plugin hook allows zero-cost vocabulary/personality transformation using more "classical" programming methods.
This follows the pattern of existing transform hooks (
transform_terminal_output,transform_tool_result):Changes
hermes_cli/plugins.pyAdded
transform_llm_outputtoVALID_HOOKSset.run_agent.pyAdded hook invocation after
final_responseis set, beforepost_llm_call.Hook Signature
Noneor empty string to pass throughtransform_tool_result)Use Case
Testing
Unit test verified:
Documentation
This hook will be documented in the plugin hooks reference alongside
transform_terminal_outputandtransform_tool_result.