Full programs: agentium-examples. Related guides: Hooks, Events.
Agent Hooks
Lifecycle hooks let you tap into key moments of an agent run — log inputs, audit tool calls, and handle errors.Loop Hooks
Loop hooks fire on every LLM roundtrip inside the agent loop. Use them to track tokens, log messages, and auto-stop when costs get too high.Cancellation
Use a standardAbortController to cancel a running agent. This is useful for enforcing hard timeouts on long-running runs.
Agent Serialization
Save an agent’s configuration to JSON and restore it later — useful for persistence, versioning, and sharing configs across services.Checkpointing
Enable checkpointing to save agent state after each tool roundtrip. Snapshots preserve data; they do not resume execution or undo external effects. See durable execution.Dependencies & Runtime Injection
Inject static values or async resolvers into the agent context. Use{key} template syntax in instructions for dynamic interpolation, and override per-run.
Context Compaction
Automatically compress conversation history when it approaches the model’s context limit. Choose trim, summarize, or hybrid strategies.trim— drops oldest non-system messages to fit the token budgetsummarize— condenses older messages into a summary using a cheaper modelhybrid— trims first, then summarizes the remaining middle section if still over budget