Debugging failing tests
Auto-debug failing tests — the crash fires the agent on its own.
Debugging failing tests
This workspace uses typed ports to fire the agent automatically when a process crashes. No copy-pasting errors into chat.
Nodes on the canvas
| Node | Role |
|---|---|
Process Manager with script npm test --watch |
Keeps tests running in a loop. |
| Code | Opens the test file and the suspect handler. |
| Terminal | For manual checks the agent suggests. |
| Agent Terminal | Receives the automatic prompt on crash. |
| Text (named "Failure log") | Logs go straight here. |
| Git | To see what changed recently that might have broken. |
Connections
| From → To | Kind | What it does |
|---|---|---|
| Process Manager → Text | port ports:logs->appendText |
Every line from the test runner becomes text. |
| Process Manager → Agent Terminal | port ports:crashes->prompt |
A crash fires an automatic prompt. |
| Agent Terminal → Code | permission code-read |
Agent opens and reads files. |
| Agent Terminal → Terminal | permission execute |
Agent runs a single test to confirm a hypothesis. |
| Agent Terminal → Git | permission git-log |
Agent looks at recent commits. |
| Agent Terminal → Text | permission summary |
Agent writes down what it found. |
How it works
- The Process Manager brings
npm test --watchup when the workspace opens (fieldautoStart: true). - Every code change reruns the test runner. Logs appear in real time in the Text via
ports:logs->appendText. - When the test runner exits with a non-zero code,
ports:crashes->promptfires — the Agent Terminal receives an automatic prompt containing the stack trace. - The agent investigates: reads the test file, reads the related handler, checks the last 5 commits via Git.
- Proposes a fix, writes the diagnosis into the "Failure log" text.
Prompt the agent receives (template)
The default prompt for the crashes->prompt port is editable on the Process Manager. Suggested template:
A process managed by Riggr crashed. Here's the stack trace:
{{logs}}
Investigate: read the test file mentioned in the error, read the
handler it covers, look at the last 5 commits via Git to see if
anything recent broke. Propose a fix (just explain, don't apply).
Write the diagnosis into the "Failure log" text node.
{{logs}} is replaced with the most recent lines that crossed the port.
Why this setup is powerful
- You don't have to be watching the terminal. You're in another tab, another tool — when you come back, the diagnosis is waiting.
- The agent works read-only on the code (
code-read). It proposes, you review. Nothing gets applied without you. - The Text is durable — it becomes a log of "this broke on day X because of Y". Useful at retro time.
Variations
- If you trust it more, swap
code-readforcode-full-accessand add to the prompt: "if the fix is trivial, apply it and tell me what changed". - For a whole team, save the workspace as a template and check it into the repo. Each person clones and starts contributing.