Skip to content
Esc
↑↓navigate↵open⌘Jpreview
Start
On this page

AI SRE Agent Architecture

How to assemble an SRE agent from Autohand Code CLI parts: sub-agents, piped data and MCP servers, structured diagnosis, patches, permission rules, hooks and traces.

Overview

Autohand Code CLI has no separate SRE agent, orchestrator service or sre command. An “SRE agent” is a normal Autohand run that you start from a script, a CI job or a terminal, with the right context, tools and limits. This guide shows how the pieces fit together.

The architecture has five parts:

  • Orchestration: the main agent delegates focused work to sub-agents you define with --agents
  • Signal input: alert payloads and logs piped in, or read through MCP servers
  • Diagnosis: a read-only run whose answer must match a JSON Schema
  • Action: fixes produced as patches, under permission rules and hooks
  • Audit and review: event streams, hooks and agent traces, plus runbooks your team updates after each incident

Orchestration with sub-agents

Define specialist sub-agents for one run with --agents. Each entry needs a description and a prompt, and can limit its tools and set a model. The main agent hands work to them with its delegate_task and delegate_parallel tools.

cat alert.json recent-errors.log \
  | autohand --ephemeral --restricted -p "Diagnose this incident. Ask log-analyst and change-reviewer in parallel, then combine their findings." \
      --agents '{
        "log-analyst": {
          "description": "Finds the first error and the failing component in log excerpts",
          "prompt": "You read logs. Report the earliest error, the component that raised it, and the timestamps. Do not change files.",
          "tools": ["read_file", "find_grep"]
        },
        "change-reviewer": {
          "description": "Checks recent commits for changes that match the failure",
          "prompt": "You review git history. List commits from the last 24 hours that touch the failing component and explain why each could matter.",
          "tools": ["read_file", "find_grep", "run_command"]
        }
      }'

To reuse the same sub-agents across runs, keep them as files in an agents directory and pass the directory path instead: --agents ./sre-agents. See Sub-agents.

Signal input

Autohand does not collect metrics, logs or traces itself. Give it the signals in one of two ways:

  • Pipe them in: fetch the alert, metrics and log excerpts with your own tools and pipe them to autohand -p. Piped input is added to the prompt as context.
  • Add an MCP server: register your monitoring vendor’s MCP server so the agent can query it during the run.
# Pipe a log excerpt and a metrics export into a run
kubectl logs deploy/payment-service --since=30m > recent-errors.log
cat alert.json recent-errors.log metrics.csv \
  | autohand --restricted -p "Summarise what these signals show."

# Or register an MCP server for your monitoring stack
autohand mcp add monitoring -- npx -y <your-monitoring-mcp-package>
autohand mcp add --transport http monitoring https://mcp.example.com/mcp

Keep log excerpts short and relevant. Filter by time window and service before piping, so the context holds the evidence rather than noise.

Diagnosis

Run the diagnosis with --restricted so nothing dangerous can run, and with --output-schema so the answer is a JSON document your automation can route on. If the answer does not match the schema, the command exits with status 1.

{
  "type": "object",
  "required": ["suspect_component", "causal_chain", "confidence", "runbook"],
  "properties": {
    "suspect_component": { "type": "string" },
    "causal_chain": { "type": "array", "items": { "type": "string" } },
    "confidence": { "type": "string", "enum": ["low", "medium", "high"] },
    "runbook": { "type": "string" }
  }
}
cat alert.json recent-errors.log \
  | autohand --ephemeral --restricted \
      -p "Diagnose this incident using the code in this repository and the runbooks in runbooks/." \
      --output-schema diagnosis.schema.json --json local \
  | jq -r .content > diagnosis.json

The causal chain is the model’s reading of the evidence you gave it. Treat confidence as a hint for routing, not a measured probability, and have a person check the chain before acting on it.

Context and memory

There is no incident database or vector store built in. The agent knows what is in the repository and what you pass to the run: runbooks, past postmortems, AGENTS.md (which autohand init creates), and any file you add with --append-system-prompt-file. Keeping postmortems in the repository is the simplest way to let later runs find similar incidents. See Memory.

Action and guardrails

Write remediation steps as Markdown runbooks in the repository, not as an action-chain config. Then ask Autohand to prepare the fix as a patch, so nothing changes until a person applies it:

autohand -p "Apply the fix in diagnosis.json, following runbooks/$(jq -r .runbook diagnosis.json)." \
  --patch --output incident-fix.patch --max-duration 600

# After review
git apply incident-fix.patch

Patch mode captures file edits instead of writing them, but it approves tool calls automatically. Add --disallowed-tools run_command,shell when the run should not execute shell commands.

Policy enforcement

Autohand does not use an external policy engine. These controls decide what a run may do:

  • permissions.denyList in the config blocks commands for every run, for example "run_command:kubectl delete:*"
  • --allowed-tools and --disallowed-tools limit the tools for one run
  • --restricted denies all dangerous operations; --plan starts in read-only plan mode
  • A pre-tool hook that exits with code 2 blocks the tool call, so you can add your own checks, such as change windows
{
  "permissions": {
    "denyList": ["run_command:kubectl delete:*", "shell:kubectl delete:*", "run_command:terraform destroy:*", "shell:terraform destroy:*"]
  },
  "hooks": {
    "enabled": true,
    "hooks": [
      {
        "event": "pre-tool",
        "matcher": "run_command",
        "command": "./scripts/check-change-window.sh"
      }
    ]
  }
}

The hook receives HOOK_TOOL and HOOK_ARGS (JSON) in its environment. Hooks do not run with --bare, so do not rely on them for runs that use it.

Audit and review

Record what each run did:

  • --output-format stream-json writes every tool event as JSON lines you can store with the incident
  • A post-tool or file-modified hook sends each action to your own log
  • autohand traces on turns on local agent trace monitoring with metadata sync to Autohand Console; autohand traces status shows the current state. See Agent traces.
cat alert.json \
  | autohand --restricted -p "Diagnose this incident." --output-format stream-json \
  > incidents/INC-1234/run.jsonl

autohand traces status

Autohand does not learn from incident outcomes or tune alert thresholds on its own. Improvement comes from your team: after each incident, have Autohand draft the postmortem and the runbook change as a patch, review it, and merge it. The next run reads the updated runbook.

cat diagnosis.json incident-timeline.md \
  | autohand -p "Write a postmortem in postmortems/ and update the matching runbook with what we learned." \
      --patch --output postmortem.patch

Integration points

Autohand reaches the rest of your stack through general interfaces, not built-in connectors:

Category How Autohand connects
Telemetry Piped exports, or an MCP server for your monitoring tool
Incident tools Your alerting system calls a script or CI job that runs autohand -p; an MCP server can read or update tickets
Knowledge Runbooks, postmortems and AGENTS.md in the repository
People Post the diagnosis and patch to your chat or ticket from the calling script
Infrastructure Shell commands through run_command, limited by permissions.denyList and hooks

Deployment considerations

Context size

  • Filter logs and metrics before piping them in
  • Use sub-agents for large searches so the main run keeps a short context
  • Set --max-duration, --max-requests and --max-tokens on unattended runs

Security and guardrails

  • Use --restricted for diagnosis and --patch for fixes, so a person approves every change
  • In CI and containers, --bare reads credentials from AUTOHAND_PROVIDER, AUTOHAND_API_KEY and AUTOHAND_AI_API_KEY; keep those in your secret store
  • Store stream-json output with the incident record as the audit trail

See Incident Response for the full flow and Headless mode for running Autohand from scripts.

Last updated on

Was this helpful?

Send Feedback

Help us improve this documentation page. Your feedback is valuable.

We'll only contact you if we need clarification