Why Sessions and Sweeps
A single experiment run produces oneExperimentResult. When you run multiple variants β a baseline, a prompt tweak, a knowledge-base variant β you need a way to group those results and track which variants have completed. Thatβs what sessions and sweeps provide.
| Concept | What it groups | Question it answers |
|---|---|---|
| RunSession | Variant results from one multi-variant run | βWhat happened in this run?β |
| Sweep | Sessions across multiple runs | βHave all expected variants been covered?β |
Hierarchy
Running with Sessions
To use sessions, create anActiveSession and pass it to AgentExperiment.run():
ActiveSession is provided:
- Traces and workspaces are written under the session directory
- The result is saved to both
ResultStore(as before) andSessionStore - Without an
ActiveSession, the experiment behaves exactly as before β full backward compatibility
SessionStore
SessionStore persists and retrieves sessions:
| Implementation | Use case |
|---|---|
FileSystemSessionStore | Production β persists to disk with atomic writes |
InMemorySessionStore | Testing β HashMap-backed |
Filesystem layout
RunSession
An immutable record representing a completed or in-progress session:| Field | Type | Description |
|---|---|---|
sessionName | String | Human-readable name (e.g., βfull-suite-2026-03-03β) |
experimentName | String | Experiment this session belongs to |
status | RunSessionStatus | RUNNING, COMPLETED, or FAILED |
variants | List<VariantEntry> | Per-variant results |
metadata | Map<String, String> | Arbitrary key-value pairs |
createdAt | Instant | Session creation timestamp |
completedAt | Instant | Null while running |
VariantEntry
Each variant within a session carries summary metrics:| Field | Type | Description |
|---|---|---|
variantName | String | Variant identifier |
experimentId | String | Unique experiment run ID |
resultFile | String | Result file relative to session |
passRate | double | Fraction passed (0.0β1.0) |
itemCount | int | Total dataset items evaluated |
costUsd | double | Total LLM cost |
durationMs | long | Wall-clock duration |
Sweeps
A sweep declares which variants must run and tracks progress across sessions. This is useful when variants run at different times β overnight jobs, CI retries, or manual re-runs of failed variants.Resolution model
When you add a session to a sweep:- The sweep loads the sessionβs variants via
SessionStore - Each variant that matches an expected variant is marked as resolved
- Last-write-wins: adding a newer session overwrites earlier resolutions for the same variant
- Session variants not in the expected list are silently ignored
- The session name is appended to
sessionHistory(append-only audit trail)
SweepStatus
| Status | Meaning |
|---|---|
RUNNING | Created, no variants resolved yet |
PARTIAL | At least one variant resolved, but not all |
COMPLETED | All expected variants resolved |
FAILED | Finalized as failed |
SweepStore
| Implementation | Use case |
|---|---|
FileSystemSweepStore | Production β persists to disk, depends on SessionStore |
InMemorySweepStore | Testing β HashMap-backed |
Version Mismatch Detection
Sweep.hasVersionMismatch() returns true if resolved variants were run against different git commits. This catches a subtle problem: when you re-run a failed variant after a code change, the sweep now contains results from two different code versions. The mismatch flag lets you detect this and decide whether to accept the mixed results or re-run the full sweep.
Related
Creating Experiments
Dataset design, variant ladders, and filtering
API Reference
ExperimentConfig, AgentInvoker, InvocationContext, ResultStore