Skip to main content

Loop Hooks

Intercept the LLM loop at every roundtrip with loopHooks. Use onRoundtripComplete to inspect token usage and optionally stop early, or onToolCall (via AgentHooks) to log each tool invocation.

Context Compaction

Automatically compact conversation history when it approaches the model’s context window limit. Choose between trimming old messages, summarizing them, or a hybrid strategy.
The three strategies:
  • trim — drops oldest non-system messages to fit the budget (fast, no LLM call)
  • summarize — condenses older messages into a summary using a cheap model
  • hybrid — trims first, then summarizes the remaining middle section if still over budget

Approval Gates

Require human approval before the agent executes specific tools. Approval can be handled via a callback or through the REST API’s event-driven approval endpoints.
For event-driven approval via the REST API:

PII Guard

Anonymize PII (emails, phone numbers, SSNs, credit cards, IP addresses) in messages before they reach the LLM. Supports redaction, hashing, and placeholder replacement with optional rehydration.
Redact mode removes PII entirely:

Checkpointing

Save and restore agent state after each tool roundtrip for crash recovery and rollback.

Discovery Cards

Generate A2A-style JSON descriptor cards for your agents’ capabilities. Useful for agent registries and multi-agent orchestration.

Metrics Export

Use MetricsExporter for per-agent dashboards with runs, errors, duration percentiles, token usage, and cost.

Dynamic Tool Resolution

Resolve tools at runtime based on user context — useful for multi-tenant setups where different users have access to different tools.

Skills and Learned Skills

Load pre-packaged skills from the filesystem or npm, and let agents save successful multi-step workflows as reusable learned skills.

Semantic Cache

Cache LLM responses by semantic similarity with configurable TTL and similarity threshold. Avoids redundant LLM calls for near-duplicate queries.

Webhooks

Push agent events to HTTP endpoints, Slack channels, or email addresses. Supports batching, retries, and event filtering.

Scheduling

Run agents on a cron schedule using AgentQueue from @agentium/queue. Requires Redis and BullMQ.

Queue Workers

Process background agent jobs with AgentWorker. Workers pull jobs from the BullMQ queue and execute agent runs with concurrency control.