archal run: your agent and harness keep
using normal service SDKs and normal service URLs. Archal handles trace import,
isolation, clone routing, scoring, artifacts, and the GitHub workflow behind
that boundary.
When to use Autoloop
Use Autoloop for a repo that has all three:- a headless command for running the agent
- traces from pre-production or production agent runs
- a GitHub repo where fixes can be proposed as PRs
How the loop works
Autoloop has two entry points:- Hosted database source:
archal autoloop --source postgres|supabase ...registers a read-only trace source with Archal. Hosted workers poll it and write run state to the dashboard. - Local trace directory:
archal autoloop ./traces --repo .watches a local directory with one trace file per run and writes repo-local artifacts under.archal/autoloop/.
| Tier | Providers | Current path |
|---|---|---|
| Supported hosted | supabase, postgres | Register with archal autoloop --source ... |
| Client upload | file, http, otel, langfuse, braintrust, s3, gcs, custom | Normalize with archal trace-source ..., then pass --upload --repository owner/repo |
archal login for local setup, or
set ARCHAL_TOKEN to a workspace API key in CI and include --repository so
Archal knows which repo should receive issues or PRs.
For pull-style sources, use archal trace-source status, sync, and watch
to inspect and advance the local source registry. For HTTP/OTel push sources,
use archal trace-source serve; watch is not the continuous path for push
sources.
The phases are:
| Phase | What Archal does | If it cannot continue |
|---|---|---|
| Import | Reads the trace and spans, then normalizes them into Archal trace evidence | Marks the source or trace as blocked with the connection or schema error |
| Grade | Decides whether the trace contains a real task failure worth reproducing | Stores the verdict and reason |
| Seed | Builds the scenario and clone seed needed to replay the trace-relevant state | Writes the missing evidence instead of guessing |
| Reproduce | Runs the generated scenario against clones with the repo harness | Marks not reproduced, flaky, or reproduced |
| Fix | Asks a coding agent to patch the harness or agent code, then validates it | Writes blocked status, issue details, or a PR |
fix is the default policy. Use a narrower policy when you only want part of
the loop.
| Policy | Stops after |
|---|---|
observe | import |
grade | grading |
reproduce | reproduction |
fix | PR or blocked fix status |
Prerequisites
- Install and log in:
ARCHAL_TOKEN to a workspace API key
(archal_ws_...). Use a personal login for local setup.
- Install the GitHub App on the target repo:
- Make sure the repo has a GitHub origin remote:
--execution-policy fix require a remote that resolves to
github.com/<owner>/<repo>.
- Add the agent execution contract under
archal/:
harness.json tells Archal how to run the agent. scenario.md gives the
standing task and evaluation contract for the trace family. Seed files are
optional, but they make reproduction much more reliable when trace evidence is
thin.
- Export the model keys your agent and the autoloop worker need.
Add the harness contract
The minimumarchal/harness.json is:
archal run: no UI, no browser OAuth, no manual prompts. It should accept the
task from AGENT_TASK, call your normal agent runtime, and exit cleanly.
Use env only for non-secret defaults that belong in the repo. Keep secrets in
your shell, CI, hosted secret manager, or Archal workspace configuration.
Add the standing scenario
archal/scenario.md is not a one-off reproduction. It is the standing contract
that tells Autoloop what the agent is supposed to do for this class of traces.
Add seed templates
Autoloop can seed from trace evidence, but the best integrations include repo-owned seed templates. Templates are especially useful when a trace contains IDs and tool calls but not the complete starting state.archal/scenario.md. The autoloop
worker prefers repo-owned seed templates when they exist, then fills in
trace-specific IDs and fields during reproduction.
See Seeds for clone seed formats and built-in examples.
Autoloop a Supabase or Postgres trace source
Use this path when traces live in a database table such asai_traces with
child spans in ai_spans.
Create a read-only database user first. It should be able to select trace and
span rows, but not mutate application data.
.archal/autoloop/.
If your secret already lives in an external secret manager, pass a reference
instead of a local environment variable:
--database-url-secret-ref must be a secret reference, not a plaintext database
URL.
Map custom trace tables
The defaults match the common shape:| Purpose | Default |
|---|---|
| Trace table | ai_traces |
| Span table | ai_spans |
| Trace id column | id |
| Span id column | id |
| Span trace id column | trace_id |
| Trace updated column | updated_at |
| Span updated column | updated_at |
| Cursor mode | updated_at_id |
created_at_id:
Filter imported traces
Use filters when the trace source contains many agents, tenants, or statuses.--source-metadata.
Autoloop a local trace directory
Use a local directory when you are testing the loop before a hosted source is ready, or when traces arrive as files../prod-traces should contain one top-level trace and enough child
span data for grading. The local loop writes artifacts under:
archal detach is for local file-backed autoloops. Hosted database sources
are managed from the dashboard.
For a terminal-first handoff, keep these commands with the artifact directory:
autoloop-status to summarize local trace jobs. Use autoloop-reprocess only
after fixing the evidence, mapping, credential, harness, or GitHub blocker that
caused a terminal job.
Dashboard pages
Autoloop results live in the workspace dashboard.| Page | Use it for |
|---|---|
| Imported traces | Source health, trace import status, grade verdicts, and blocked reasons |
| Reproduced failures | Seed evidence, reproduction status, clone parity, and run artifacts |
| Opened issues/PRs | GitHub issue links, PR links, branch names, check status, and residual risk |
- Did Archal receive the trace?
- Did Archal reproduce a real failure against clones?
- Did Archal open something reviewable in GitHub?
Artifact contract
Hosted sources surface these artifacts in the dashboard. Local file-backed local autoloops write the same kinds of artifacts under.archal/autoloop/.
| Artifact | Purpose |
|---|---|
routing.json | What trace was imported and how it moved through the loop |
grade.json | Grade verdict, failure summary, evidence, and whether reproduction should continue |
scenario.md | Generated reproduction scenario for the trace |
seed.json | Generated seed request or materialized seed metadata |
manifest.json | Phase status, commands, attempts, evidence, and output paths |
stdout.json | Machine-readable output from the reproduction run |
stderr.log | Reproduction command stderr |
status.json | Fix status when a run blocks before a patch or PR |
pr-details.md | Review summary for a generated fix |
repo.patch | Patch captured from the fix worker when a PR cannot be opened |
Troubleshooting
No traces import
Check:archal loginorARCHAL_TOKEN- GitHub origin remote
- the read-only database URL
- table and column mappings
--source-status,--source-agent-id, and other filters- whether
updated_atorcreated_atvalues move past the stored cursor
archal autoloop --check ... with the same source flags to validate setup
without registering or starting work.
Hosted source registration fails
Common causes:- no logged-in Archal account
- missing
ARCHAL_TOKENin CI --database-url-envpoints to an unset environment variable--database-url-secret-refcontains a plaintext credential- repo remote is missing or is not GitHub
Reproduction is blocked as missing evidence
That usually means the trace does not contain enough state to build the starting clone state. Add one of:- richer trace fields such as
input_data,output_data, state snapshots, or tool-call arguments - child spans for service reads and writes
- repo-owned seed templates under
archal/seeds/ - a narrower
archal/scenario.mdthat tells Archal what state matters
A PR is not opened
Check:- the execution policy is
fix - the GitHub App is installed on the repo
- the repo has an origin remote on GitHub
- reproduction status is
reproducedorflaky - generated changes pass local validation
- GitHub branch protection and CI status
Safety
- Use read-only trace source credentials.
- Do not commit database URLs, API keys, or model keys.
- Prefer
--database-url-envfor local setup and secret references for hosted production setup. - Keep trace artifacts redacted before sharing them outside the workspace.
- Do not add model-visible copy telling the tested agent it is in Archal or a clone-backed run.
- Let the GitHub App open PRs; do not bypass the review path with direct pushes to protected branches.
