Learn
AI SRE Agent

AI SRE Agent

The Traceway AI SRE agent (opens in a new tab) answers production errors with pull requests. It runs on your own machine or a server you control, watches Traceway, and when a new error is reported it starts Claude Code or Codex in a fresh git worktree of your code. The coding tool finds the root cause with the traceway CLI, proves a fix with your tests, and the agent opens a draft pull request that explains what happened. When the cause is not in the code, such as infrastructure or a dependency, it opens a GitHub issue instead. If the error paged someone, the agent acknowledges the page once the pull request is open; when it cannot fix the error, the page keeps escalating to people.

The agent never merges anything. Pull requests open as drafts, so a person still decides what ships.

AI SRE agentAuto-Fix
Where it runsYour machine or server, as a background serviceYour repository's GitHub Actions
How it learns about an errorPolls Traceway every 30 secondsTraceway opens a GitHub issue, which starts a workflow
Coding toolClaude Code or Codex, already logged in on the machineClaude Code with an API key in CI, or your own agent
On-call pagesCan acknowledge themNot involved

This page covers what the agent reacts to, what Traceway needs for it to get work, and how to tell why it is idle. Every config option is in the agent's README (opens in a new tab) and its config.example.yaml (opens in a new tab).

What the agent reacts to

The agent reads two sources, both on by default:

SourceWhat it readsWhat Traceway needs
pagesOpen on-call pages. The only kind the agent can acknowledge.An alert rule that sends to an escalation policy channel, with a policy and a schedule behind it. Without one, Traceway never opens a page.
alert_historyNotifications that alert rules already sent to an ordinary channel: email, Slack, Telegram, a webhook and so on.Only the alert rules. Needs traceway CLI 2.0.11 or newer.

Most teams start with rules that send email or Slack and have no on-call schedule. For them alert_history is the source that matters. With sources: [pages] and no escalation channel the agent polls forever and never gets work.

By default the agent only reacts to two rule types: new_error (New Issue) and error_regression (Error Regression). Both point at one issue with a stack trace, which the agent can fix in code. Latency, Apdex, metric and other alerts are ignored, because otherwise every one of those notifications would start a job. The filter applies to both sources:

traceway:
  sources: [pages, alert_history]              # the default
  rule_types: [new_error, error_regression]    # the default; [] reacts to every rule type

Add rule types such as endpoint_p95_threshold, apdex_drop or metric_threshold to have the agent investigate those alerts too.

alert_history looks back 60 minutes on every poll (alert_history_lookback_minutes). An alert sent while the agent was stopped for longer than that is not picked up. Run it by hand instead.

What Traceway needs

  1. An error rule in every project the agent watches. Create a New Issue rule, and an Error Regression rule if you archive fixed issues, as in Alerts, Step 2. Any channel works. A rule that already emails your team is enough.
  2. For pages, an escalation channel. Follow On-Call through Step 4. To have the agent take only the pages meant for it, put a member for the agent on the schedule and set only_paged_user in its config.
  3. For acknowledging pages, Agent Access. An organization admin turns on Settings > Agent Access > Allow agent writes. See Agent Write Access. Without it the agent still opens pull requests, but pages keep escalating.

Set it up

Install

curl -fsSL https://raw.githubusercontent.com/tracewayapp/traceway-ai-sre-agent/main/scripts/install.sh | sh

This puts traceway-sre-agent in ~/.local/bin. It runs on Linux and macOS as your own user. The machine also needs git with push access to your repositories, gh logged in, and claude or codex logged in.

Log in the Traceway CLIs

The agent reads Traceway through the traceway CLI and acknowledges pages through traceway-write. Install both:

curl -fsSL https://cli.tracewayapp.com/install.sh | sh
curl -fsSL https://cli.tracewayapp.com/install.sh | sh -s -- --write

Log traceway in with a read-only personal access token, in a profile of its own. Pick No expiration or note the expiry date:

traceway login --url https://cloud.tracewayapp.com --profile sre --token-stdin

Prefer a token for the agent over a browser login. A browser login renews itself every 15 minutes with a refresh token that works once. If the CLI cannot save the renewed login, for example because the disk is full, it presents the old refresh token on the next poll, the server ends the session, and the agent stops reading Traceway until someone logs in again. A token has nothing to renew.

Log traceway-write in only if the agent should acknowledge pages. A write token must expire within 90 days, so a browser login is the practical choice here:

traceway-write login --url https://cloud.tracewayapp.com --profile sre

Configure

Create the config from the example and fill in your projects:

mkdir -p ~/.config/traceway-sre-agent
curl -fsSL https://raw.githubusercontent.com/tracewayapp/traceway-ai-sre-agent/main/config.example.yaml \
  -o ~/.config/traceway-sre-agent/config.yaml

A complete config:

agent:
  tool: claude-code          # or codex
  model: opus
  effort: high
 
traceway:
  server_url: https://cloud.tracewayapp.com
  profile: sre               # the profile you logged `traceway` in with
  write_profile: sre         # the profile you logged `traceway-write` in with
 
projects:
  - traceway_project: My Backend          # project name or id in Traceway
    repos:
      - path: ~/code/my-backend           # local checkout of its code
        allowed_commands: ["go test ./..."]   # what the agent may run to prove a fix

traceway-sre-agent config shows which config file is in use and ends with It loads without errors. when it is valid.

Check and start it

traceway-sre-agent --check            # every tool, login, project and repository
traceway-sre-agent service install    # run in the background, start at login

--check prints a line per dependency and the command that fixes each failure. On Linux, run loginctl enable-linger $USER once to keep the service running while you are logged out.

Check that it works

The service log is ~/.local/state/traceway-sre-agent/logs/service.log. Its first lines name the sources in use:

INFO polling every 30s, https://cloud.tracewayapp.com: My Backend -> 1 repo(s) tool="Claude Code" model="opus" effort="high" sources=[Pages, AlertHistory]

To see what the agent would do with the notifications pending right now, without running the coding tool, pushing or opening anything:

traceway-sre-agent --once --dry-run

Run one job by hand

trigger runs the whole pipeline for one issue without waiting for an alert. Use it for an issue that fired before the agent was running:

traceway-sre-agent trigger --project "My Backend" --issue 927eb0316311e138

The issue hash is the 16 characters after /issues/ in the issue's URL.

When the agent does nothing

Work through these in order:

  1. The log says sources=[Pages]. The config pins the agent to on-call pages. Unless a rule in the project sends to an escalation channel, add alert_history to sources and restart the service.
  2. The alert's rule type is filtered out. Only new_error and error_regression are handled by default. Compare the rule type in the project's notification history with rule_types.
  3. The notification is older than the lookback. alert_history only sees the last 60 minutes. Use trigger.
  4. The log says could not poll the ... source. The agent logs a failing source once and stays quiet until it recovers, when it logs the ... source recovered. The usual cause is a login that ended. Run traceway --profile sre projects list to see the error, log in again, and the agent recovers on its next poll without a restart.
  5. The agent has nothing in its state. ~/.local/state/traceway-sre-agent/state.json lists every notification the agent handled. An empty handled means it never picked one up.
⚠️

A failing source is easy to miss, because the agent keeps running. Give the agent a project of its own in Traceway, set its telemetry section so its failures arrive there as issues, and add a New Issue rule to that project that notifies you.