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.
Description
I'd like to propose this new hook
agent_output_parser
, which allows developers to replace the default output parser (StrOutputParser
) used by the Cat agent.Similar to
rabbithole_instantiates_splitter
, this hook prioritizes the last parser defined if multiple plugins use the same hook.Why?
Currently, the agent’s output is a simple string, which is limiting for certain use cases. Some would argue that is possible to enrich
CatMessage
using thebefore_cat_sends_message
hook, but this approach requires a bunch of custom code and for structured outputs may involve an additional LLM call leading to increased latency and costs.Agents are often used beyond conversational contexts, especially in deterministic workflows where structured outputs are central. Just like we've seen recently with frameworks like PydanticAI.
Example of Usage
As you can see, the
agent_output_parser
does not work by itself. You need to provide the agent instructions on how to format the output of the chain.However, with just a few lines of code you can build a support agent with structured outputs to be used in your own application flow.
Doubts
The
agent_output_parser
works within theMemoryAgent
flow and some would argue that MemoryAgent should strictly handle memory-related tasks, but since it is our final step in the flow, it makes it a logical place to apply this hook.I know it's time to pause a little and build more instead of overthink and cumulate too many features. This is why the draft PR. Let's see it it gather interest.
Type of change
Checklist: