Scenarios
A scenario is the top-level configuration for a simulation run. It defines:name— identifier for the scenarioseed— deterministic RNG seed (same seed = same results)ticks— number of simulation stepstickSeconds— simulated time per tick (e.g., 3600 = 1 hour)pack— protocol adapter that sets up world stateagents— list of agent types, counts, and parametersassertions— post-run validation checksgossip— channel definitions, budgets, and trust settings
Ticks
A tick is one simulation step. During each tick:- The engine calls
step(ctx)on every agent in order - Each agent returns zero, one, or up to three actions
- The pack executes each action against the protocol state
- Metrics, gossip, and artifacts are recorded
Agents
Agents are autonomous actors. Every agent extendsBaseAgent and implements step():
Agent Context
Each tick, agents receive aTickContext with:
| Property | Description |
|---|---|
ctx.rng | Deterministic random number generator |
ctx.world | Current protocol state |
ctx.gossip | Read and post gossip messages |
ctx.capabilities | Available contracts, tools, and action templates |
ctx.tick | Current tick number |
ctx.tickSeconds | Simulated seconds per tick |
Agent State
Agents can persist state across ticks:this.remember(key, value)— store a valuethis.recall(key)— retrieve a stored valuethis.setCooldown(name, ticks)— rate-limit an actionthis.isOnCooldown(name)— check cooldown status
Multi-Action Support
Agents can return an array of up to 3 actions per tick. The engine executes each action in order within the same tick:Persona LLM Agents
PersonaLlmAgentBase provides a reusable base for LLM-driven agents with:
- Persona profile (id, style, goals, risk profile, tool preferences)
- Structured prompt assembly with full capability manifest context
- Two-stage OODA loop: plan then act, with fallback to single-shot parsing
- Schema-validated action intents via Zod
Packs
Packs are protocol adapters. They bridge AgentForge to your smart contracts by implementing thePack interface:
setup()— deploy contracts, initialize stateexecuteAction(action)— execute an agent’s action against the protocolgetWorldState()— return current protocol state for agents to observegetCapabilityManifest()— describe available contracts, functions, and action templates
ToyPack provides a simple price-simulation environment for getting started.
Gossip
The gossip bus enables inter-agent communication:- Channels — global broadcast or scoped strategy channels with membership lists
- Free-form messages — text payloads with optional
credibilityPriorscores (0-1) - Budgets — configurable
maxPostsPerTickandmaxReadsPerTickper agent - Cooldowns — per-channel
postCooldownTicksto rate-limit posting
Determinism
Same seed + same scenario = identical results. All randomness flows through a seeded RNG. This enables:- Reproducible CI — assertions pass or fail consistently
- Replay — re-run exploration traces deterministically against updated contracts
- Comparison — diff two runs with
forge-sim compare
Exploration / Replay Workflow
- Explore — run with LLM agents in exploration mode to discover behaviors
- Capture — a
replay_bundle.jsonrecords the full decision trace - Replay — re-run the exact same trace deterministically against updated contracts