API Reference¶
Complete API documentation for ProactiveAgent components and configuration options.
Overview¶
ProactiveAgent is built with a modular architecture that allows you to customize every aspect of your agent's behavior:
- ProactiveAgent - Main agent class that orchestrates everything
- Providers - LLM provider integrations (OpenAI, etc.)
- Decision Engines - Logic for when to respond
- Sleep Calculators - Timing between decision cycles
- Scheduler - Wake-up timing and pattern management
Quick Navigation¶
Core Components¶
- ProactiveAgent - The main agent class
Integrations¶
- Providers - LLM provider abstractions
Customization¶
- Decision Engines - Control when your agent responds
- Sleep Calculators - Control timing between checks
- Scheduler - Internal scheduler implementation
Providers¶
Providers are the interface between ProactiveAgent and LLM services. Use the built-in OpenAIProvider or create your own.
Creating a Custom Provider¶
Extend the BaseProvider class and implement the generate_response method:
Configuration¶
The decision_config dictionary controls all aspects of timing and decision-making. This configuration is available to both decision engines and sleep calculators.
Standard Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
min_response_interval | int | 30 | Minimum seconds between agent responses |
max_response_interval | int | 600 | Maximum seconds between agent responses |
engagement_threshold | float | 0.5 | Threshold for combined decision score (0.0-1.0) |
engagement_high_threshold | int | 10 | User messages in last hour for "high" engagement |
engagement_medium_threshold | int | 3 | User messages in last hour for "medium" engagement |
context_relevance_weight | float | 0.4 | Weight for context relevance in decision |
time_weight | float | 0.3 | Weight for time elapsed in decision |
probability_weight | float | 0.3 | Weight for AI probability in decision |
wake_up_pattern | str | - | Natural language description of wake pattern |
min_sleep_time | int | 30 | Minimum seconds between wake cycles |
max_sleep_time | int | 600 | Maximum seconds between wake cycles |
Example with All Parameters¶
Custom Parameters¶
You can extend decision_config with your own parameters. This is useful when you need to pass configuration to custom decision engines or sleep calculators without hardcoding values.
The config dictionary is passed to both decision engines and sleep calculators, allowing you to access any parameters you define:
In this example: - priority_mode and custom_check_interval are custom parameters not part of the standard configuration - They're accessed in CustomSleepCalculator using config.get() with sensible defaults - This keeps configuration flexible and external to the implementation
The config dictionary is available in: - DecisionEngine.should_respond(config=...) - SleepTimeCalculator.calculate_sleep_time(config=...)
Custom Decision Engines¶
Decision engines control whether the agent should respond. Create custom engines by extending the DecisionEngine base class.
Basic Example¶
Context Dictionary¶
The context dictionary contains conversation state:
| Python | |
|---|---|
Add custom context when sending messages:
| Python | |
|---|---|
Custom Sleep Calculators¶
Sleep calculators control when the agent wakes up next. Create custom calculators by extending the SleepTimeCalculator base class.
Basic Example¶
When to Use Custom Implementations¶
| Use Case | Recommended Approach |
|---|---|
| Simple timing rules | FunctionBasedDecisionEngine |
| Custom LLM/API | Custom Provider |
| Complex decision logic | Custom DecisionEngine |
| Dynamic sleep timing | Custom SleepTimeCalculator |
| Full control over behavior | Combine custom components |
Built-in Components¶
Decision Engines¶
AIBasedDecisionEngine(default) - Uses LLM to evaluate context and decideThresholdBasedDecisionEngine- Priority-based rules with configurable thresholdsFunctionBasedDecisionEngine- Custom logic using Python functionsSimpleDecisionEngine- Always responds (useful for testing)
Sleep Calculators¶
AIBasedSleepCalculator(default) - Uses LLM to determine sleep time based on contextStaticSleepCalculator- Fixed intervals regardless of contextPatternBasedSleepCalculator- Adjust timing based on conversation keywordsFunctionBasedSleepCalculator- Custom logic using Python functions
Detailed Documentation¶
For detailed API documentation of each component, see:
- ProactiveAgent - Main agent class
- Providers - LLM provider interfaces
- Decision Engines - Decision engine implementations
- Sleep Calculators - Sleep calculator implementations
- Scheduler - Internal scheduler