GitHub
Examples

Rollout Memory

Simulate future scenarios and evaluate potential outcomes (Planning).

Intelligence Module
Scenario: Deciding advice for Emma's knee pain

When to Use

Advanced agents don't just react; they think ahead. Rollout memory allows the agent to simulate different response paths and evaluate which is best before replying. Perfect for:

  • Planning agents (Chain of Thought simulations)
  • Risk assessment (Simulating dangerous advice)
  • A/B testing responses internally

Key Operations

simulate()

Create a branched simulation

evaluate_branch()

Score a branch outcome

Code Example

Emma complains of knee pain. The agent simulates two branches: "Suggest Rest" vs "Suggest Pushing Through".

# 1. Simulate Scenarios
simulation = client.memory.rollouts.simulate(
rollout_id="sim_knee_pain",
query="Emma: My knees really hurt after that run.",
branches=[
{"id": "b1", "action": "Suggest rest", "rationale": "Safety"},
{"id": "b2", "action": "Push through", "rationale": "Resilience"}
],
depth=1
)
# 2. Evaluate Outcomes (e.g., using a Critic Model)
# Branch 1 aligns with her 'safety' preference, so it scores higher
client.memory.rollouts.evaluate_branch(
rollout_id="sim_knee_pain",
branch_id="b1",
score=0.9,
feedback="Safe and supportive"
)
client.memory.rollouts.evaluate_branch(
rollout_id="sim_knee_pain",
branch_id="b2",
score=0.2,
feedback="Risky, ignores medical history"
)

Key Takeaways

  • Tree of Thought: Stores a tree of possible futures.
  • Use it to filter bad actions before they reach the user.
  • Unlike other memories (which are past/present), this is memory of possible futures.