`agent_fast_reply`
Shorten the pipeline and return an answer right after the agent execution.
This hook allows for a custom response after memory recall, skipping default agent execution. It’s useful for custom agent logic or when you want to use recalled memories, but you want to avoid the main agent.
📄 Arguments
Section titled “📄 Arguments”| Name | Type | Description |
|---|---|---|
fast_reply |
dict |
An initially empty dict that can be populated with a response. |
cat |
Cat | Cheshire Cat instance, allows you to use the framework components. |
↩️ Return
Section titled “↩️ Return”Type: None | dict | AgentOutput
If you want to bypass the main agent, return an AgentOutput or a dict with an output key.
Return None to continue with normal execution.
✍ Example
Section titled “✍ Example”The cat has no memory (no uploaded document) about a specific topic:
from cat.mad_hatter.decorators import hook
@hook # default priority = 1def agent_fast_reply(fast_reply, cat): # answer with predefined sentences if the Cat # has no knowledge in the declarative memory # (increasing the threshold memory is advisable) if len(cat.working_memory.declarative_memories) == 0: fast_reply["output"] = "Sorry, I have no memories about that."
return fast_reply