Skip to main content

Why Providers?

Your agent needs to understand the world around it. Without context, it’s flying blind:
  • Who is the user? What’s their history?
  • What actions are available right now?
  • What does the agent know about this topic?
Providers are the senses of your agent. They gather data from memory, services, and external sources, then feed it into the LLM prompt.
Think of providers as context injectors. Each provider contributes a piece of the puzzle - conversation history, user facts, available actions - assembled into the prompt at runtime.

Provider Interface

Providers supply contextual information that forms the agent’s understanding of the current situation. They gather data from various sources to build comprehensive state.

Core Interface

Provider Types

  • Standard Providers: Included by default in state composition
  • Dynamic Providers: Only executed when explicitly requested
  • Private Providers: Internal use only, not exposed in default state

Built-in Providers

Provider Summary Table

Provider Details

Actions Provider (ACTIONS)

Lists all available actions the agent can execute.
  • Position: -1 (runs early)
  • Dynamic: No (included by default)
  • Data Provided:
    • actionNames: Comma-separated list of action names
    • actionsWithDescriptions: Formatted action details
    • actionExamples: Example usage for each action
    • actionsData: Raw action objects

Action State Provider (ACTION_STATE)

Shares execution state between chained actions.
  • Position: 150 (runs later)
  • Dynamic: No (included by default)
  • Data Provided:
    • actionResults: Previous action execution results
    • actionPlan: Multi-step action execution plan
    • workingMemory: Temporary data shared between actions
    • recentActionMemories: Historical action executions

Character Provider (CHARACTER)

Core personality and behavior definition.
  • Dynamic: No (included by default)
  • Data Provided:
    • agentName: Character name
    • bio: Character background
    • topics: Current interests
    • adjective: Current mood/state
    • directions: Style guidelines
    • examples: Example conversations/posts

Recent Messages Provider (RECENT_MESSAGES)

Provides conversation history and context.
  • Position: 100 (runs later to access other data)
  • Dynamic: No (included by default)
  • Data Provided:
    • recentMessages: Formatted conversation history
    • recentInteractions: Previous interactions
    • actionResults: Results from recent actions

Facts Provider (FACTS)

Retrieves contextually relevant stored facts.
  • Dynamic: Yes (must be explicitly included)
  • Behavior: Uses embedding search to find relevant facts
  • Data Provided:
    • Relevant facts based on context
    • Fact metadata and sources

Relationships Provider (RELATIONSHIPS)

Social graph and interaction history.
  • Dynamic: Yes (must be explicitly included)
  • Data Provided:
    • Known entities and their relationships
    • Interaction frequency
    • Relationship metadata

State Composition

The composeState method aggregates data from multiple providers to create comprehensive state.

Method Signature

Parameters

  • message: The current message/memory object being processed
  • includeList: Array of provider names to include (optional)
  • onlyInclude: If true, ONLY include providers from includeList
  • skipCache: If true, bypass cache and fetch fresh data

Composition Process

  1. Provider Selection: Determines which providers to run based on filters
  2. Parallel Execution: Runs all selected providers concurrently
  3. Result Aggregation: Combines results from all providers
  4. Caching: Stores the composed state for reuse

Usage Patterns

Provider Registration

Registering a Provider

Providers are registered during plugin initialization:

Provider Position

Position determines execution order:

Custom Providers

Creating a Custom Provider

Provider Best Practices

  1. Return quickly: Use timeouts for external calls
  2. Handle errors gracefully: Return empty result on failure
  3. Keep data size reasonable: Don’t return excessive data
  4. Use appropriate flags: Set dynamic for optional providers
  5. Consider position: Order matters for dependent providers

Provider Dependencies

Providers can access data from previously executed providers through the state parameter:

State Cache Management

Cache Architecture

The runtime maintains an in-memory cache of composed states:

Cache Usage

Cache Optimization

Provider Execution Flow

Performance Optimization

Parallel Execution

Providers run concurrently for optimal performance:

Timeout Handling

Implement timeouts to prevent slow providers from blocking:

Common Issues and Solutions

Circular Dependencies

Avoid providers that depend on each other circularly:

Memory Leaks

Prevent memory leaks with proper cache management:

Debugging State Composition

See Also

Models

Learn how models use provider context

Services

Build services that use providers

Messaging

Real-time provider updates

Sessions API

See providers in conversational context