Skip to content
amareshhebbarPublic

About

Find the exact step where an AI agent run went wrong, and prove the fix by replay.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

25 Commits

Folders and files

Repository files navigation

Rootcast

Your AI agent failed in production but did not crash. Rootcast shows you which step went wrong and why. A developer tool for agents running in production

PyPI npm License Python


Hackathon submission

Rootcast is our entry for the HackCulture Global AI Hackathon.

Theme AI Agents and Intelligent Systems
Problem statement Build a Benchmarking Platform for AI Agents, Not Just Models
Demo video demo/rootcast-demo.mp4
Pitch deck demo/Rootcast.pdf
Team Amaresh Hebbar and Ashutosh

Model benchmarks score one answer. Agents fail somewhere inside a chain of steps, and the final answer hides where. Rootcast benchmarks the agent, not the model:

  • Every step of a run gets its own PASS, WARN or FAIL score from real signals: errors, stale data, type drift, mismatched inputs and empty results.
  • Every failed run gets a root cause: the earliest step whose output broke everything after it.
  • Every root cause gets a proof: replay the run with that one step fixed and the run must flip from FAIL to PASS. A cause that does not flip is not reported as proven.
  • The same trace format and the same scores come from Python and Node agents, so two agents built on different stacks are judged by one standard.

The three sample runs in examples/traces cover three different agent failure modes (stale data, wrong retrieval, bad tool argument). The engine names the right cause on all three, and the test suite asserts it.


The problem

When you run an AI agent that does many steps (search, read a file, call a tool, decide, act), sometimes it quietly does the wrong thing. It does not crash. It just produces an answer that looks fine but is actually wrong. You only find out later, when it is already a problem.

Right now, when that happens, all you get is a long boring log of what the agent did. You stare at it and try to guess where it went wrong. It is like a crime scene with no detective.

The idea

Build a black box recorder for AI agents, like the flight recorder in planes.

While the agent works, Rootcast quietly records why it made each choice, not just what it did. Then when something goes wrong, Rootcast:

  1. Shows the chain of decisions as a simple map, not a wall of text.
  2. Points to the exact step where things first went off the rails (maybe step 7 failed, but the real mistake was back at step 3 when a tool gave bad info).
  3. Lets you hit replay and change one thing, like "what if that bad info was not there?", and see if the agent would have gotten it right.

So instead of guessing, you get a clear answer: here is where it broke, and here is what caused it.


Try it in one minute

From a clone of this repo (Python 3.9 or newer, no other dependencies):

git clone https://github.com/amareshhebbar/RootCast.git
cd RootCast
pip install -e packages/python
rootcast audit examples/traces/stale_policy.rootcast.json
rootcast replay examples/traces/stale_policy.rootcast.json --agent examples/scenarios/stale_policy.py --set step2.output=policy_2026
rootcast serve --open

Or from PyPI, with nothing to clone:

pip install rootcast
rootcast demo
rootcast audit rootcast-demo/stale_policy.rootcast.json
rootcast replay rootcast-demo/stale_policy.rootcast.json --set step2.output=policy_2026
rootcast serve --open

rootcast demo writes three real failed agent runs (a stale policy lookup, a RAG retrieval of the wrong document, a tool called with a malformed argument). audit names the step that caused the failure, replay proves it by flipping the run from FAIL to PASS, and serve opens the decision map in your browser with the samples ready to click. The Node SDK is on npm as rootcast and writes the same trace files.

See it in thirty seconds

Today, when an agent fails, you read this:

[12:04:01] tool_call search(query="refund policy 2024")
[12:04:02] tool_result "... 847 tokens of text ..."
[12:04:03] llm_call messages=[...]
[12:04:05] llm_result "Based on the policy the refund window is 90 days"
[12:04:06] tool_call issue_refund(order=4417, reason="within window")
[12:04:07] tool_result {"status":"ok"}
... 40 more lines ...

With Rootcast, you read this:

run refund-7af3  FAIL  refund issued outside the 30 day policy window

  step1  read_order     ok
  step2  lookup_policy  CAUSE  returned 2024 data, read_order is 2026
  step3  decide_refund  ok
  step4  issue_refund   FAIL   refund issued outside the 30 day policy window

  earliest divergence: step2
  chain: step2 -> step3 -> step4
  cause: lookup_policy: returned 2024 data, read_order is 2026, and that fed issue_refund

  flags:
    step2  WARN  stale       returned 2024 data, read_order is 2026
    step4  FAIL  step_error  refund issued outside the 30 day policy window

That is the real output of rootcast audit examples/traces/stale_policy.rootcast.json. Then prove it:

$ rootcast replay examples/traces/stale_policy.rootcast.json --agent examples/scenarios/stale_policy.py --set step2.output=policy_2026
replay refund-7af3  --set step2.output=policy_2026

  step1  read_order     unchanged   ok
  step2  lookup_policy  injected    ok
           output.source       "policy_2024" -> "policy_2026"
           output.window_days  90 -> 30
           output.year         2024 -> 2026
  step3  decide_refund  recomputed  ok
           inputs.policy.source       "policy_2024" -> "policy_2026"
           inputs.policy.window_days  90 -> 30
           inputs.policy.year         2024 -> 2026
           output.allowed             true -> false
           output.policy_source       "policy_2024" -> "policy_2026"
           output.window_days         90 -> 30
  step4  issue_refund   recomputed  FAIL -> ok
           inputs.decision.allowed        true -> false
           inputs.decision.policy_source  "policy_2024" -> "policy_2026"
           inputs.decision.window_days    90 -> 30
           output.status                  "issued" -> "denied"
           output.violation               "outside_window" -> null

  changed: step2, step3, step4
  untouched: step1
  run: FAIL -> PASS  (flipped)

Same run. One tells you what happened. The other tells you what to fix, and proves it: the agent decided correctly, but the policy lookup handed it the 2024 policy for a 2026 order. Swap in the 2026 policy and only the steps downstream of the lookup change, the order read stays untouched, and the run flips from FAIL to PASS. Both commands run as is from a clone of this repo.

Prefer pictures? rootcast serve --open opens the decision map in your browser: drop in a trace, the cause is highlighted, click it, pick a value and hit Run replay to watch the banner flip to PASS. See docs/ui.md.


Quickstart

Python:

pip install rootcast
from rootcast import Recorder

rec = Recorder(run_id="refund-7af3")

with rec.step("read_order", kind="tool") as s:
    order = get_order(4417)
    s.output(order)

with rec.step("lookup_policy", kind="tool") as s:
    policy = search_policy("refund window")
    s.input({"query": "refund window"})
    s.output(policy)

rec.save("refund-7af3.rootcast.json")

Then, from the terminal:

rootcast view refund-7af3.rootcast.json
rootcast audit refund-7af3.rootcast.json

Node:

npm install rootcast
import { Recorder } from "rootcast";

const rec = new Recorder({ runId: "refund-7af3" });

const lookupPolicy = rec.record(searchPolicy, { kind: "tool" });
const policy = await lookupPolicy("refund window");

await rec.step("decide_refund", { kind: "decision" }, (s) => {
  s.output(decide(order, policy));
});

rec.save("refund-7af3.rootcast.json");

Both SDKs write the same trace file, byte for byte, with the same inferred dependencies. One recorder format, any language, any framework. File naming and the multi run store are in docs/trace-files.md.


How it works

Rootcast has three layers. Each one is useful on its own, and they stack.

Layer 1: Capture

A thin recorder wraps each step your agent takes. It records the inputs, the outputs, the model messages, the tool results, and the timing, into one portable trace file. The recorder never changes what your agent does. It only watches. Overhead is kept low by storing references and hashes for large payloads instead of copying them inline.

Supported out of the box: a generic context manager and decorator that fit any Python or Node agent, plus adapters for common frameworks (LangGraph, CrewAI, and the generic OpenAI and Anthropic tool loops). The trace schema is public and versioned, so you can emit it from anywhere.

Layer 2: Causal engine

This is the detective. Given a trace, Rootcast builds a decision graph: every step becomes a node, and an edge means one step's output fed another step's decision. It then walks the graph backward from the failure to find the earliest divergence point, the first step whose output, had it been correct, would have changed everything downstream.

Each step is scored PASS, WARN, or FAIL, and the one step that most likely caused the failure is tagged CAUSE. This is not a keyword match on the logs. It is a dependency walk over what actually fed what.

Layer 3: Replay

Finding the suspect is good. Proving it is better. Replay re-runs a trace with exactly one variable changed, for example the result of step 3, and reports whether the outcome flips from FAIL to PASS. Deterministic steps are served from the recorded cache so the replay is fast and cheap, and only the changed branch is recomputed. This turns "I think step 3 caused it" into "step 3 caused it, here is the proof."


The trace format

Everything in Rootcast is built on one small, stable JSON schema. If you can write this file, every Rootcast feature works on your agent, whatever stack you built it on.

{
  "rootcast_version": "0.1",
  "run_id": "refund-7af3",
  "status": "fail",
  "steps": [
    {
      "id": "step3",
      "name": "lookup_policy",
      "kind": "tool",
      "inputs": { "query": "refund window" },
      "output_ref": "sha256:9f2c...",
      "depends_on": ["step1"],
      "started_at": 1730650800.21,
      "ended_at": 1730650800.63
    }
  ]
}

depends_on is the heart of the system. It is what lets the causal engine tell a step that merely ran before the failure from a step that actually fed the failure. When your framework does not declare dependencies, Rootcast infers them from data flow between inputs and outputs.


Why this is different

There are three kinds of tools in this space, and they do not overlap with Rootcast.

  • Observability dashboards show you traces. They tell you what happened. They do not tell you which step caused the failure.
  • Model benchmarks and eval tools score final answers against fixed tasks. They tell you a pass rate. They do not tell you which step inside the agent failed, or prove it.
  • Guardrails block bad actions before they happen. They do not help once a quiet failure already slipped through.

Rootcast is the missing middle: it benchmarks the agent step by step, and for every run that went wrong it gives you the cause and the fix, with proof.


Roadmap

Shipped in v0.2.0:

  • Trace schema v0.1, frozen, with byte identical Python and Node recorders and dependency inference
  • Causal engine: decision graph, PASS WARN FAIL scoring, anomaly flags, earliest divergence and CAUSE
  • Replay engine: single variable counterfactual, recorded cache for unchanged steps, step by step outcome diff
  • Web UI: interactive decision map with click to replay, served by rootcast serve

Next:

  • Framework adapters for LangGraph, CrewAI and the OpenAI and Anthropic tool loops
  • Live streaming capture from running agents

See planning-execute.md for the full phased build with task owners.


Documentation

Topic Doc
Recording a run from Python or Node docs/recording.md
Every CLI command docs/cli.md
How the audit scores steps and names the cause docs/audit.md
Replay and writing a replay agent docs/replay.md
The web UI docs/ui.md
Trace schema and canonical encoding docs/trace-schema.md
Trace file naming and the trace store docs/trace-files.md
Releasing both packages docs/releasing.md

Contributing

Rootcast is Apache 2.0 and open to contributors. The trace schema in docs/trace-schema.md is the contract: anything that reads or writes it is a valid Rootcast tool. Start there.


Built by Amaresh Hebbar and Ashutosh.

About

Find the exact step where an AI agent run went wrong, and prove the fix by replay.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages