agent-core crate provides the central agent execution engine, managing agent lifecycle, tool execution, and conversation orchestration with security and memory integration.
agent::chat
Process a message through the agent loop with tool execution, security checks, and memory storage.Unique identifier for the agent to process the message
User message to process through the agent
Optional session identifier for conversation tracking. Defaults to
default:{agentId}Optional system prompt override. Falls back to agent config if not provided
The assistant’s response content
Model information used for the completion
Token usage statistics (input, output, total)
Number of tool execution iterations performed (max 50)
Total execution time in milliseconds
Security Integration
The agent::chat function automatically performs:- Injection scanning - Scans user messages for prompt injection patterns (threshold: 0.5 risk score)
- Capability checks - Validates tool access before execution via
security::check_capability - Token quota enforcement - Tracks and enforces max_tokens_per_hour limits
Tool Execution Loop
The agent executes tools in an iterative loop with a maximum of 50 iterations:- Route to optimal model via
llm::route - Generate completion with available tools
- If tool calls present:
- Check capability for each tool
- Execute tool via III trigger
- Append results to conversation
- Request next completion
- Store conversation in memory
- Update metering statistics
agent::create
Register a new agent with configuration including model preferences, capabilities, and resource limits.Optional agent ID. Auto-generates UUID if not provided
Display name for the agent
Optional description of the agent’s purpose
Default system prompt for the agent
Optional array of string tags for organization
The created or assigned agent ID
agent::list
List all registered agents in the system.Array of agent configuration objects with id, name, description, model, capabilities, etc.
List Agents
agent::delete
Remove an agent from the system and publish lifecycle event.ID of the agent to delete
Returns true if deletion was successful
Delete Agent
Deleting an agent publishes an
agent.lifecycle event with type “deleted”.agent::list_tools
List tools available to a specific agent based on its capability configuration.ID of the agent to query tools for
Array of available tool definitions with id, description, and parameters
List Tools
Tool Filtering Logic
- If capabilities include
"*"or empty list: returns all tools - If specific prefixes defined (e.g.,
["file::", "memory::"]): filters by prefix match - Wildcard patterns are stripped (e.g.,
"file::*"becomes"file::")
Configuration
AgentConfig Type
Constants
- MAX_ITERATIONS: 50 - Maximum tool execution iterations per chat request
- Default Session ID:
default:{agentId}- Auto-generated if not provided
Event Publishing
The agent-core worker publishes lifecycle events to theagent.lifecycle topic:
Queue Triggers
The agent::chat function is triggered by messages published to theagent.inbox topic, enabling async agent message processing.