[!NOTE] Implemented (issue #107). The user documentation is in investigate failures and A2A.
Status: accepted (#107). Tickets 1 to 5 are implemented. The user guide is failure investigations.
When a step of a run fails, Saci can start an investigation. An investigation is an agent task that:
Other agents, CI jobs and outcome actions request investigations over the A2A protocol. The A2A request only starts the work. The agent does all other work, the bug report included.
The source code is a required input. A result that only repeats the failure, without a cause in the code, is not a conclusion. See Source code.
An outcome action is one MCP call that must answer within
limits.operation_timeout_secs (default 120 seconds). A clone and a code
analysis take longer. The script runner also stops
the process group of a script when the script exits, so a script cannot
continue the work in the background. An investigation needs its own
budget, evidence, cancellation and record. The worker already supplies
these for test runs.
flowchart LR
caller["A2A client<br/>agent, CI, outcome action"]
subgraph backend["saci-backend"]
a2a["A2A endpoint<br/>message/send, tasks/get, tasks/cancel"]
store[("SQLite store<br/>runs and investigations")]
supervisor["Supervisor and launcher"]
end
worker["saci-worker<br/>investigation mode"]
git["Source repositories"]
tracker["Bug tracker<br/>MCP server"]
caller --> a2a
a2a --> store
supervisor -- launch --> worker
worker -- "events and evidence" --> backend
worker --> git
worker --> tracker
conclude call.tasks/get. The completed task
contains the analysis and the bug link.These parts stay as they are:
The image already contains git, ssh, curl and jq.
The worker gets a second mode. The mode follows from the specification. Nothing else in the worker checks the mode.
| Part | Test run | Investigation |
|---|---|---|
| System prompt | agent/prompt.rs: do exactly the written step, do not invent repairs. |
A second preamble: explore the source, form hypotheses, cite evidence, do not change the system under test or push to repositories. |
| Work | Plan units in order, with the run policy (sequence.rs). |
One task with a deadline and the configured call limits. |
| Finishing tool | assess: expected results to an outcome. |
conclude: summary, hypotheses with confidence and evidence IDs, the bug link or the reason that no bug was filed. |
| Result | Unit and run outcomes. | An investigation result (see below). |
Tool output stays evidence, never instructions, in both modes.
The code is an input of the investigation, as the failure is. The agent must find the cause in the code, not only describe the symptom.
Which repositories. The investigations configuration lists the
repositories, each with a name, URL, default ref and description. A
request can select repositories by name and give a ref for each, for
example the commit or tag that the system under test runs. A request
cannot add a URL that is not in the configuration.
Getting the code. The worker clones each repository into
/workspace/src/<name> and checks out the ref before the first model
request. It records the resolved commit SHA of each repository as
evidence. When a clone or checkout fails, the investigation ends with
result error and the reason. No model request is made, because an
analysis without the code is not useful.
Reading the code. The agent uses the shell tool on the clones, for
example grep, git log, git blame and git show. The prompt tells
the agent to:
Code references. Each hypothesis cites one or more source locations:
repository name, path, line range and commit SHA. The worker checks each
location mechanically, as it checks evidence IDs in an assessment. The
commit must be a cloned commit, and the path and lines must exist at it.
A conclude call with an invalid location is rejected, and the agent can
correct it. Result concluded needs at least one hypothesis with a valid
location. Without one, the result is inconclusive, with the reason.
Context budget. Investigations must work with small models and short context windows. A grep-and-read loop fills the context fast, so the design limits it in four ways:
ripwire . --for="<symptom>" --token-budget=4000 and
ripwire . --from-trace=<file>. The agent calls it with the shell
tool. Its CLI costs less context than MCP tool definitions. Saci does
not depend on ripwire: the configuration names the tool and how to use
it.investigations.prepare lists commands that
the worker runs in each clone before the first model request, for
example a ripwire --for query built from the failed step. Their output
is evidence in the first prompt, so the model starts from a map, not
from an empty directory. A command that fails is recorded and does not
stop the investigation.limits, with a
smaller output_limit_bytes (for example 8192) than test runs.Usage guidance for the code map tool goes in the investigation
instructions, which play the role of a skill. The Saci image contains
ripwire. investigations.image selects an image that adds other tools,
for example one built FROM the Saci image.
The bug report. The filed bug contains the failed step, the observed and expected results, the hypotheses, and links to the cited code at the cloned commit.
RunSpec keeps its bundle field for test runs and gets an optional
investigation field. Exactly one of the two is set. A test run keeps
its format, so SCHEMA_VERSION stays 1 and stored runs stay readable.
A worker that does not know investigations rejects the specification,
because it has an unknown field.
investigation:
parent_run: run-0f3c9a2b7d4e4f1a9b8c7d6e5f4a3b2c
plan_title: Orders smoke test
unit: # the failed unit's report, copied by the backend
key: "1.2"
title: Check orders
outcome: failed
attempts: [...] # assessments, errors
evidence: [...] # the evidence that the attempts cite
repositories: # from the configuration, refs from the request
- name: orders-service
url: https://github.com/example/orders-service.git
ref: v2.4.1
description: The orders REST service.
instructions: |
File bugs in example/orders-service with the `create_issue` tool.
Search for an open issue with the same cause first.
The investigation result:
| Field | Meaning |
|---|---|
result |
concluded, inconclusive, error or cancelled. |
summary |
A short analysis. |
sources |
Each cloned repository with its resolved commit SHA. |
hypotheses |
Each has a statement, a confidence (high, medium, low), evidence IDs and code locations (repository, path, lines, commit). |
bug |
The URL and title of the filed or existing bug, or absent. |
no_bug_reason |
Why no bug was filed, when bug is absent. |
An investigation does not use the test outcomes (passed, failed, …).
A “passed” investigation has no clear meaning.
A new backend section. It reuses an environment for the secrets and MCP servers that the agent needs, for example a Git token and a tracker MCP server.
investigations:
environment: investigator # an entry of environments:
repositories:
- name: orders-service
url: https://github.com/example/orders-service.git
ref: main
description: The orders REST service.
prepare: # run in each clone, before the model
- 'ripwire . --for=": " --token-budget=4000'
instructions: |
Find code with `ripwire . --for="..."` and `ripwire . --callers=NAME`.
Read only the lines it points to. Do not read whole files.
File bugs in example/orders-service with the `create_issue` tool.
limits:
run_timeout_secs: 1800
output_limit_bytes: 8192
prepare commands can use ,, ,
and ``. The worker replaces each
variable with a reference to an environment variable that holds the
value, for example ${SACI_FAILURE_TITLE}, so a value cannot change the
command. Quote a variable where the shell must not split the value.
Without this section, the A2A endpoint is not served.
The backend serves a minimal A2A subset over JSON-RPC 2.0. It uses the
same client token as the REST API. The methods are served at POST /a2a.
| Method | Behavior |
|---|---|
GET /.well-known/agent-card.json |
The agent card: one skill, investigate-failure. capabilities.streaming and capabilities.pushNotifications are false. |
message/send |
Creates an investigation and returns the task in state submitted. The backend does not wait for the investigation, also when blocking is true. |
tasks/get |
The task state. A completed task has two artifacts: the result as a data part and the summary as a text part. |
tasks/cancel |
Requests cancellation, as for a run. |
The request is a message with one data part:
{
"run_id": "run-0f3c9a2b7d4e4f1a9b8c7d6e5f4a3b2c",
"unit": "1.2",
"sources": [{ "name": "orders-service", "ref": "v2.4.1" }]
}
unit is optional. Without it, the backend selects the first unit with
outcome failed, error or blocked.sources is optional. Without it, the agent gets every configured
repository at its default ref. A name that is not in the configuration
is rejected.rejected) when the run is
not finished, the unit did not fail, or the run is itself an
investigation.State mapping:
| Investigation | A2A task state |
|---|---|
| queued | submitted |
| running | working |
concluded, inconclusive |
completed |
error |
failed |
cancelled |
canceled |
The first trigger needs no new backend code: an outcome action on
[failed] calls a script runner tool. The script sends message/send
with curl, with the action’s idempotency_key as the message ID, and
returns the task ID at once. This is a second example next to
examples/script-runner/email.
When investigations become a core feature, a native action type in the backend can replace the script. It is not part of this design.
saci investigate <run-id> [--unit <key>] starts an investigation, and
saci investigations show <id> shows it.message/stream) and push notifications.investigation in RunSpec, the
investigation request and result, the investigations configuration.prepare commands
before the first model request, the second preamble, the conclude
tool with code location checks, and one task with a deadline.saci investigate.message/send, tasks/get and
tasks/cancel, with deduplication and state mapping.docs/run-tests/investigate-failures.md.Tickets 2 and 3 depend on 1. Ticket 4 depends on 3. Tickets 5 and 6 depend on 4.