Skip to main content

Module behavioral_simulator

Module behavioral_simulator 

Source
Expand description

AI Behavioral Simulation Engine

This module provides functionality to model users as narrative agents that:

  • React to app state (e.g., “cart is empty” → intention: “browse products”)
  • Form intentions (shop, browse, buy, abandon)
  • Respond to errors (rage clicking on 500 errors, retry logic, cart abandonment on payment failure)
  • Trigger multi-step interactions automatically
  • Maintain session context across interactions

§Persona Integration Strategy

  • Primary: Augment existing personas - Attach behavior policies to existing Smart Personas
  • Secondary: Generate new personas - When system description introduces roles that don’t exist

§Example Usage

use mockforge_core::ai_studio::behavioral_simulator::{BehavioralSimulator, CreateAgentRequest};
use mockforge_core::intelligent_behavior::IntelligentBehaviorConfig;

async fn example() -> mockforge_core::Result<()> {
    let config = IntelligentBehaviorConfig::default();
    let simulator = BehavioralSimulator::new(config);

    let request = CreateAgentRequest {
        persona_id: Some("existing-persona-123".to_string()),
        behavior_policy: Some("bargain-hunter".to_string()),
        generate_persona: false,
    };

    let agent = simulator.create_agent(&request).await?;
    Ok(())
}

Structs§

AppState
App state awareness
BehaviorPolicy
Behavior policy attached to persona
BehavioralSimulator
Behavioral Simulator Engine
BehavioralTraits
Behavioral traits for the agent
CartItem
Cart item
CartState
Cart state
CreateAgentRequest
Request to create a narrative agent
ErrorEncounter
Error encounter
Interaction
Interaction record
NarrativeAgent
Narrative agent that models user behavior
NextAction
Next action to take
PolicyRule
Policy rule for behavior
SimulateBehaviorRequest
Request to simulate behavior
SimulateBehaviorResponse
Response from behavior simulation

Enums§

Intention
User intention types