Comprehensive documentation on the composeState method in elizaOS and how it interacts with different types of providers to build contextual state for agent decision-making
composeState
method in elizaOS and how it interacts with different types of providers to build contextual state for agent decision-making.
composeState
method is a core function in elizaOS that aggregates data from multiple providers to create a comprehensive state object. This state represents the agent’s understanding of the current context and is used for decision-making, action selection, and response generation.
Provider Name | Dynamic | Position | Default Included | Purpose |
---|---|---|---|---|
ACTIONS | No | -1 | Yes | Lists available actions |
ACTION_STATE | No | 150 | Yes | Action execution state |
ANXIETY | No | Default | Yes | Response style guidelines |
ATTACHMENTS | Yes | Default | No | File/media attachments |
CAPABILITIES | No | Default | Yes | Service capabilities |
CHARACTER | No | Default | Yes | Agent personality |
CHOICE | No | Default | Yes | Pending user choices |
ENTITIES | Yes | Default | No | Conversation participants |
EVALUATORS | No | Default | No (private) | Post-processing options |
FACTS | Yes | Default | No | Stored knowledge |
PROVIDERS | No | Default | Yes | Available providers list |
RECENT_MESSAGES | No | 100 | Yes | Conversation history |
RELATIONSHIPS | Yes | Default | No | Social connections |
ROLES | No | Default | Yes | Server roles (groups only) |
SETTINGS | No | Default | Yes | Configuration state |
TIME | No | Default | Yes | Current UTC time |
WORLD | Yes | Default | No | Server/world context |
ACTIONS
)actionNames
: Comma-separated list of action namesactionsWithDescriptions
: Formatted action detailsactionExamples
: Example usage for each actionactionsData
: Raw action objectsACTION_STATE
)actionResults
: Previous action execution resultsactionPlan
: Multi-step action execution planworkingMemory
: Temporary data shared between actionsrecentActionMemories
: Historical action executionsANXIETY
)ATTACHMENTS
)CAPABILITIES
)CHARACTER
)agentName
: Character namebio
: Character backgroundtopics
: Current interestsadjective
: Current mood/statedirections
: Style guidelinesexamples
: Example conversations/postsCHOICE
)ENTITIES
)FACTS
)PROVIDERS
)RECENT_MESSAGES
)RELATIONSHIPS
)ROLES
)SETTINGS
)TIME
)WORLD
)composeState
method uses an in-memory cache (stateCache
) to store composed states:
onlyInclude
for performance-critical pathscomposeState
method is central to elizaOS’s context management system. It provides a flexible way to aggregate data from multiple sources, manage caching for performance, and create rich contextual state for agent decision-making. By understanding how to effectively use providers and manage state composition, you can build more intelligent and context-aware agents.
Key takeaways: