Features
Counterfactual replay
Re-run an agent tool call with modified parameters and compare outcomes side by side.
Counterfactual replay
On any agent tool call in chat, choose Try alternative to re-execute with edited parameters. Original and alternative results appear side by side.
Console
In the agent tool thread panel (CounterfactualReplayPanel / CounterfactualCompare):
- Expand a completed tool call.
- Edit JSON parameters.
- Replay. The worker runs dry-run for side-effect tools.
- Compare outputs in the two-column view.
Requires agent runs stored with tool traces (default for WorkflowAgent).
Guardrails
- Side-effect tools (send message, HTTP POST, etc.) run in dry-run mode.
- Max one nested counterfactual level per run.
- Stored in
agent_runs_counterfactual(D1).
API
POST /rooms/:roomId/agent-runs/:runId/counterfactual
GET /rooms/:roomId/agent-runs/:runId/counterfactualSDK
const alt = await client.replayCounterfactual(roomId, {
runId: originalRunId,
toolCallId,
modifiedParams: { query: "alternative search terms" },
});