Self-Heal
Self-Heal investigates agent issues — errors, behavior drift, guard violations — using trace data and source code, then opens pull requests with fixes.
How it works
- Signal — an error, a drift, or a guard violation appears in the trace
- Diagnosis — Staso reads the trace and your source at the exact failing version, traces the failure to its root cause
- Fix PR — a pull request with the proposed fix, ready to review and merge
Quick vs. Deep
Every diagnosis runs at one of two depths.
| Quick | Deep | |
|---|---|---|
| Reads | Spans, errors, guard violations, source code at the failing version | Everything in Quick, plus full repo clone with code execution |
| Traces across files | Individual file reads only | Follows imports, searches symbols, traces call chains |
| Fix PRs | No | Writes the fix, pushes a branch, opens a PR |
| Speed | Seconds | Slower — clones and executes in a sandbox |
| Runs when | Default | Pick Deep in the depth selector, or escalate from a Quick result |
Quick requires a GitHub connection for source-aware analysis. Without it, diagnosis runs on trace data alone.
Deep runs are covered in Deep Runs.
Running a diagnosis
Open a failing trace, switch to the Heal tab, and click Diagnose. You can type a specific question — "why did this return None?", "is this a regression?" — or describe a symptom.
Staso investigates in real time. You see each tool call and file read as it happens.
The result includes a root cause, a proposed fix, and the option to turn it into a pull request.
Follow-ups
Diagnosis is conversational. After the initial result, ask follow-up questions in the same thread. Each follow-up carries the full trace and prior diagnosis context — Staso builds on what it already found rather than starting over.
Fix PRs
When a Deep diagnosis produces a fix, Staso writes the change, creates a branch, and opens a PR against your repo. You review the diff inline before visiting GitHub.
No fix reaches your code without your approval. The sandbox is scoped to that single fix and torn down immediately after.
Fix PRs require Deep runs and a GitHub connection.
Conversations
Heal works at the conversation level too. Open a conversation, switch to the Heal tab, and diagnose across all traces in the session — useful when a failure spans multiple agent turns.
Prerequisites
| Requirement | Enables | Setup |
|---|---|---|
| Staso SDK | All diagnosis | Quickstart |
| GitHub connection | Source-aware diagnosis, Fix PRs | Connect GitHub |
| Deep runs enabled | Multi-file tracing, Fix PRs | Deep Runs |
Without GitHub, diagnosis runs on trace data alone. Without Deep runs, diagnosis still works but Fix PRs are disabled.