@elizaos/core v1.0.0-beta.34 / AgentRuntime
Class: AgentRuntime
Represents the runtime environment for an agent.
Implements
Implements
IAgentRuntime
Accessors
db
Get Signature
get db():
any
Database instance
Returns
any
Implementation of
IAgentRuntime.db
Defined in
packages/core/src/runtime.ts:1475
Methods
registerPlugin()
registerPlugin(
plugin
):Promise
<void
>
Registers a plugin with the runtime and initializes its components
Parameters
• plugin: Plugin
The plugin to register
Returns
Promise
<void
>
Implementation of
IAgentRuntime.registerPlugin
Defined in
packages/core/src/runtime.ts:189
getConversationLength()
getConversationLength():
number
Get the number of messages that are kept in the conversation buffer.
Returns
number
The number of recent messages to be kept in memory.
Implementation of
IAgentRuntime.getConversationLength
Defined in
packages/core/src/runtime.ts:632
registerProvider()
registerProvider(
provider
):void
Register a provider for the agent to use.
Parameters
• provider: Provider
The provider to register.
Returns
void
Implementation of
IAgentRuntime.registerProvider
Defined in
packages/core/src/runtime.ts:651
registerAction()
registerAction(
action
):void
Register an action for the agent to perform.
Parameters
• action: Action
The action to register.
Returns
void
Implementation of
IAgentRuntime.registerAction
Defined in
packages/core/src/runtime.ts:660
registerEvaluator()
registerEvaluator(
evaluator
):void
Register an evaluator to assess and guide the agent's responses.
Parameters
• evaluator: Evaluator
The evaluator to register.
Returns
void
Implementation of
IAgentRuntime.registerEvaluator
Defined in
packages/core/src/runtime.ts:681
registerContextProvider()
registerContextProvider(
provider
):void
Register a context provider to provide context for message generation.
Parameters
• provider: Provider
The context provider to register.
Returns
void
Defined in
packages/core/src/runtime.ts:689
processActions()
processActions(
message
,responses
,state
?,callback
?):Promise
<void
>
Process the actions of a message.
Parameters
• message: Memory
The message to process.
• responses: Memory
[]
The array of response memories to process actions from.
• state?: State
Optional state object for the action processing.
• callback?: HandlerCallback
Optional callback handler for action results.
Returns
Promise
<void
>
Implementation of
IAgentRuntime.processActions
Defined in
packages/core/src/runtime.ts:700
evaluate()
evaluate(
message
,state
,didRespond
?,callback
?,responses
?):Promise
<Evaluator
[]>
Evaluate the message and state using the registered evaluators.
Parameters
• message: Memory
The message to evaluate.
• state: State
The state of the agent.
• didRespond?: boolean
Whether the agent responded to the message.~
• callback?: HandlerCallback
The handler callback
• responses?: Memory
[]
Returns
Promise
<Evaluator
[]>
The results of the evaluation.
Implementation of
IAgentRuntime.evaluate
Defined in
packages/core/src/runtime.ts:796
ensureParticipantInRoom()
ensureParticipantInRoom(
entityId
,roomId
):Promise
<void
>
Ensures a participant is added to a room, checking that the entity exists first
Parameters
• entityId: `${string}-${string}-${string}-${string}-${string}`
• roomId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<void
>
Implementation of
IAgentRuntime.ensureParticipantInRoom
Defined in
packages/core/src/runtime.ts:999
ensureWorldExists()
ensureWorldExists(
__namedParameters
):Promise
<void
>
Ensure the existence of a world.
Parameters
• __namedParameters: World
Returns
Promise
<void
>
Implementation of
IAgentRuntime.ensureWorldExists
Defined in
packages/core/src/runtime.ts:1054
ensureRoomExists()
ensureRoomExists(
entityId
):Promise
<void
>
Ensure the existence of a room between the agent and a user. If no room exists, a new room is created and the user and agent are added as participants. The room ID is returned.
Parameters
• entityId: Room
The user ID to create a room with.
Returns
Promise
<void
>
The room ID of the room between the agent and the user.
Throws
An error if the room cannot be created.
Implementation of
IAgentRuntime.ensureRoomExists
Defined in
packages/core/src/runtime.ts:1090
composeState()
composeState(
message
,filterList
,includeList
):Promise
<State
>
Composes the agent's state by gathering data from enabled providers.
Parameters
• message: Memory
The message to use as context for state composition
• filterList: string
[] = null
Optional list of provider names to include, filtering out all others
• includeList: string
[] = null
Optional list of private provider names to include that would otherwise be filtered out
Returns
Promise
<State
>
A State object containing provider data, values, and text
Implementation of
IAgentRuntime.composeState
Defined in
packages/core/src/runtime.ts:1115
useModel()
useModel<
T
,R
>(modelType
,params
):Promise
<R
>
Use a model with strongly typed parameters and return values based on model type
Type Parameters
• T extends string
The model type to use
• R = ModelResultMap
[T
]
The expected return type, defaults to the type defined in ModelResultMap[T]
Parameters
• modelType: T
The type of model to use
• params: any
The parameters for the model, typed based on model type
Returns
Promise
<R
>
- The model result, typed based on the provided generic type parameter
Implementation of
IAgentRuntime.useModel
Defined in
packages/core/src/runtime.ts:1290
getTaskWorker()
getTaskWorker(
name
):TaskWorker
Get a task worker by name
Parameters
• name: string
Returns
TaskWorker
Implementation of
IAgentRuntime.getTaskWorker
Defined in
packages/core/src/runtime.ts:1469
init()
init():
Promise
<void
>
Initialize database connection
Returns
Promise
<void
>
Implementation of
IAgentRuntime.init
Defined in
packages/core/src/runtime.ts:1479
close()
close():
Promise
<void
>
Close database connection
Returns
Promise
<void
>
Implementation of
IAgentRuntime.close
Defined in
packages/core/src/runtime.ts:1483
getAgents()
getAgents():
Promise
<Agent
[]>
Get all agents
Returns
Promise
<Agent
[]>
Implementation of
IAgentRuntime.getAgents
Defined in
packages/core/src/runtime.ts:1491
getEntityById()
getEntityById(
entityId
):Promise
<Entity
>
Get entity by ID
Parameters
• entityId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Entity
>
Implementation of
IAgentRuntime.getEntityById
Defined in
packages/core/src/runtime.ts:1511
getEntitiesForRoom()
getEntitiesForRoom(
roomId
,includeComponents
?):Promise
<Entity
[]>
Get entities for room
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
• includeComponents?: boolean
Returns
Promise
<Entity
[]>
Implementation of
IAgentRuntime.getEntitiesForRoom
Defined in
packages/core/src/runtime.ts:1515
createEntity()
createEntity(
entity
):Promise
<boolean
>
Create new entity
Parameters
• entity: Entity
Returns
Promise
<boolean
>
Implementation of
IAgentRuntime.createEntity
Defined in
packages/core/src/runtime.ts:1519
updateEntity()
updateEntity(
entity
):Promise
<void
>
Update entity
Parameters
• entity: Entity
Returns
Promise
<void
>
Implementation of
IAgentRuntime.updateEntity
Defined in
packages/core/src/runtime.ts:1526
getComponent()
getComponent(
entityId
,type
,worldId
?,sourceEntityId
?):Promise
<Component
>
Get component by ID
Parameters
• entityId: `${string}-${string}-${string}-${string}-${string}`
• type: string
• worldId?: `${string}-${string}-${string}-${string}-${string}`
• sourceEntityId?: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Component
>
Implementation of
IAgentRuntime.getComponent
Defined in
packages/core/src/runtime.ts:1530
getComponents()
getComponents(
entityId
,worldId
?,sourceEntityId
?):Promise
<Component
[]>
Get all components for an entity
Parameters
• entityId: `${string}-${string}-${string}-${string}-${string}`
• worldId?: `${string}-${string}-${string}-${string}-${string}`
• sourceEntityId?: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Component
[]>
Implementation of
IAgentRuntime.getComponents
Defined in
packages/core/src/runtime.ts:1539
createComponent()
createComponent(
component
):Promise
<boolean
>
Create component
Parameters
• component: Component
Returns
Promise
<boolean
>
Implementation of
IAgentRuntime.createComponent
Defined in
packages/core/src/runtime.ts:1543
updateComponent()
updateComponent(
component
):Promise
<void
>
Update component
Parameters
• component: Component
Returns
Promise
<void
>
Implementation of
IAgentRuntime.updateComponent
Defined in
packages/core/src/runtime.ts:1547
deleteComponent()
deleteComponent(
componentId
):Promise
<void
>
Delete component
Parameters
• componentId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<void
>
Implementation of
IAgentRuntime.deleteComponent
Defined in
packages/core/src/runtime.ts:1551
getMemories()
getMemories(
params
):Promise
<Memory
[]>
Get memories matching criteria
Parameters
• params
• params.entityId?: `${string}-${string}-${string}-${string}-${string}`
• params.agentId?: `${string}-${string}-${string}-${string}-${string}`
• params.roomId?: `${string}-${string}-${string}-${string}-${string}`
• params.count?: number
• params.unique?: boolean
• params.tableName: string
• params.start?: number
• params.end?: number
Returns
Promise
<Memory
[]>
Implementation of
IAgentRuntime.getMemories
Defined in
packages/core/src/runtime.ts:1582
createRelationship()
createRelationship(
params
):Promise
<boolean
>
Creates a new relationship between two entities.
Parameters
• params
Object containing the relationship details
• params.sourceEntityId: `${string}-${string}-${string}-${string}-${string}`
• params.targetEntityId: `${string}-${string}-${string}-${string}-${string}`
• params.tags?: string
[]
• params.metadata?
Returns
Promise
<boolean
>
Promise resolving to boolean indicating success
Implementation of
IAgentRuntime.createRelationship
Defined in
packages/core/src/runtime.ts:1745
updateRelationship()
updateRelationship(
relationship
):Promise
<void
>
Updates an existing relationship between two entities.
Parameters
• relationship: Relationship
The relationship object with updated data
Returns
Promise
<void
>
Promise resolving to void
Implementation of
IAgentRuntime.updateRelationship
Defined in
packages/core/src/runtime.ts:1754
getRelationship()
getRelationship(
params
):Promise
<Relationship
>
Retrieves a relationship between two entities if it exists.
Parameters
• params
Object containing the entity IDs and agent ID
• params.sourceEntityId: `${string}-${string}-${string}-${string}-${string}`
• params.targetEntityId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Relationship
>
Promise resolving to the Relationship object or null if not found
Implementation of
IAgentRuntime.getRelationship
Defined in
packages/core/src/runtime.ts:1758
getRelationships()
getRelationships(
params
):Promise
<Relationship
[]>
Retrieves all relationships for a specific entity.
Parameters
• params
Object containing the user ID, agent ID and optional tags to filter by
• params.entityId: `${string}-${string}-${string}-${string}-${string}`
• params.tags?: string
[]
Returns
Promise
<Relationship
[]>
Promise resolving to an array of Relationship objects
Implementation of
IAgentRuntime.getRelationships
Defined in
packages/core/src/runtime.ts:1765
sendControlMessage()
sendControlMessage(
params
):Promise
<void
>
Sends a control message to the frontend to enable or disable input
Parameters
• params
Parameters for the control message
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
The ID of the room to send the control message to
• params.action: "disable_input"
| "enable_input"
The action to perform
• params.target?: string
Optional target element identifier
Returns
Promise
<void
>