[BUG] Nasty side effect in hook before_cat_sends_message
#1043
Labels
bug
Something isn't working
hooks
Make the cat extensible via plugins hooks
mad hatter
Related to the plugin system
If you call
cat.llm
from within thebefore_cat_sends_message
hook, model interactions are not saved in the finalCatMessage.why.model_interactions
. Example:The LLM is actually used and the joke added to the reply, but since
MadHatter.execute_hook
stores the originalCatMessage
and passes to each hook a deepcopy of it, when the second is returned and overwritten on the first, some info gets lost.This only happens in hooks having side effects on the same data structure passed by argument to the hook.
The example above does not incur in the same bug with other hooks.
A possible solution is to avoid deepcopying the hook argument?
It was there to avoid side effects in the first place XD.
Also, this kind of stuff should be heavily tested, at the MadHatter class level tests.
Nasty one
The text was updated successfully, but these errors were encountered: