Execution Hooks
Execution hooks provide powerful extension points to customize and enhance agent behavior at runtime. Agent Kernel supports pre-execution hooks and post-execution hooks that allow you to modify prompts, inject context, validate inputs, and transform responses.
Session & Memory Access
Hooks have full access to the session object and auxiliary memory (volatile and non-volatile caches). This enables:
- Accessing and modifying session state
- Storing temporary data in volatile cache (RAG context, files)
- Persisting preferences in non-volatile cache (user settings, metadata)
Learn about session management → | Learn about memory management →
Overview
Hooks enable you to:
- Inject Context: Add RAG (Retrieval-Augmented Generation) context to prompts
- Validate Input: Implement guardrails to filter inappropriate content
- Modify Responses: Transform or enrich agent replies
- Logging & Analytics: Track execution patterns and user interactions
- Content Moderation: Apply safety filters to inputs and outputs
Current Limitation
Hooks currently execute only for the initial user prompt to the first agent. Agent-to-agent handoffs within workflows are not yet instrumented. This limitation will be addressed in a future release.