agentRegistry
VoltAgent Service / agentRegistry
agentRegistry
Functions
loadDatabaseAgents()
loadDatabaseAgents():
Promise<Record<string,Agent>>
Defined in: agentRegistry.ts:121
Load all active agents from database.
Returns a record of agent_key -> Agent instances. Includes system agents, org agents, and user agents (no filtering).
MUST guards:
- Skip agents where active_version_id IS NULL
- Skip agents where version status != 'active'
- Skip agents where active_version_id != version.id (mismatch)
Error handling:
- Invalid configs: Log ERROR and skip agent
- DB errors: Log WARN and return (graceful degradation)
Returns
Promise<Record<string, Agent>>
mergeAgentRegistries()
mergeAgentRegistries(
codeAgents,dbAgents):Record<string,Agent>
Defined in: agentRegistry.ts:288
Merge code-based and database agents with conflict resolution.
Priority (highest to lowest):
- Database agents (org/user agents)
- Database system agents
- Code-based agents
System agent visibility:
- System agents (organization_id IS NULL AND user_id IS NULL) are visible to all
- Org/user agents with same agent_key override system agents
- Database agents always override code agents with same key
Returns:
- Merged agent registry (agent_key -> Agent)
- Conflict count for logging
Parameters
codeAgents
Record<string, Agent>
dbAgents
Record<string, Agent>
Returns
Record<string, Agent>
countConflicts()
countConflicts(
codeAgents,dbAgents):number
Defined in: agentRegistry.ts:315
Count conflicts between code and database agents. Conflicts are agent_key values that exist in both registries.
Parameters
codeAgents
Record<string, Agent>
dbAgents
Record<string, Agent>
Returns
number
References
closeVoltagentPool
Re-exports closeVoltagentPool