v2.5.9
March 10, 2026
Build smarter tool hooks with access to the full conversation history
Tool pre- and post-hooks, as well as agent-level tool_hooks, can now read the current run's complete message history via run_context.messages. This makes it straightforward to build hooks that inspect prior conversation turns for auditing, conditional logic, prompt injection detection, or logging without needing to pass history through separate channels.
Details:
run_context.messagesis available in both pre- and post-hooks at the tool and agent level- Enables hooks to make decisions based on the full conversation up to the current tool call
- No changes required to existing hooks that don't need message history; fully backward-compatible
See cookbook for reference.
