AI Agents for DevOps and SRE: Safe Incident Response, Change Control, and Production Automation
A practical guide to AI agents for DevOps and SRE: incident investigation, approval gates, typed tools, safe remediation, verification, rollback, security, and evaluation.
By BoundLayer Engineering Team
BoundLayer is a senior engineering partner for SaaS, fintech, AI automation, cloud infrastructure, legacy modernization, Web3, IoT, GPU computing, and data systems.
AI agents are moving into operations for a practical reason: production incidents create more information than one engineer can process quickly.
A responder may need to correlate alerts, traces, logs, deployments, feature flags, cloud events, database health, recent tickets, and service ownership before deciding what happened. The slow part is often not typing a command. It is collecting evidence, reconstructing context, and choosing an action under pressure.
An operations agent can shorten that loop. It can gather evidence, build a timeline, match symptoms to known failure modes, propose a runbook, and prepare a change. But an agent that can reason about production is not automatically an agent that should control production.
The right architecture separates reasoning from authority. Models can investigate broadly and recommend actions, while deterministic systems enforce identity, scope, approvals, execution, verification, and rollback.
This guide explains how to build AI agents for DevOps and SRE without turning probabilistic output into unrestricted production access.
Why agentic operations is becoming a serious engineering category
The operational use of AI is shifting from chat-based assistance toward systems that can inspect tools, maintain incident context, and coordinate multi-step workflows.
Google has described how its SRE teams use agentic AI to support production operations while preserving reliability controls in its guide to AI in SRE practice. AWS frames production agents around six responsibilities: build, test, run, secure, observe, and govern in its production AI agent walkthrough.
These systems are useful because operations work contains both deterministic and interpretive tasks.
Deterministic tasks include:
- querying a metric or deployment API;
- comparing configuration versions;
- executing an approved rollback;
- scaling a known service within a policy limit;
- creating an incident channel;
- recording a timeline event.
Interpretive tasks include:
- deciding which signals are relevant;
- connecting symptoms across services;
- summarizing a noisy event stream;
- generating competing hypotheses;
- identifying missing evidence;
- recommending the next diagnostic step.
Agents are strongest when they perform the interpretive work and invoke deterministic tools through controlled interfaces.
Start with the operational outcome, not the model
“Add an AI agent to DevOps” is not a useful implementation requirement. Start with a measurable workflow.
Good initial outcomes include:
- reduce time to assemble incident context;
- improve alert triage consistency;
- detect the most likely change associated with a regression;
- answer service ownership and runbook questions;
- produce a complete incident timeline automatically;
- draft remediation changes for review;
- validate that a rollback restored service health;
- identify recurring toil from incident and ticket history.
Define the baseline before implementation. Measure current median time to acknowledge, time to first useful hypothesis, time to mitigation, number of escalations, false-positive rate, and responder effort.
The agent should improve a specific part of that system. A general-purpose production agent with broad credentials is difficult to evaluate and nearly impossible to govern.
A production architecture for an SRE agent
A safe operations agent is a control system with several independent layers.
1. Event intake and incident state
The workflow may begin from an alert, support escalation, deployment failure, anomaly detector, or human request. Normalize the trigger into a structured incident record containing:
- incident ID and severity;
- affected services and environments;
- alert source and timestamps;
- initiating user or system;
- current owner and escalation policy;
- links to dashboards, traces, deployments, and runbooks;
- workflow state and approval state.
Keep this record outside the model context. The model can receive a view of the state, but a durable workflow or database should remain the source of truth.
For incidents that may run for hours, use durable orchestration rather than an in-memory agent loop. Our guide to durable execution for business workflows covers retries, timers, human approvals, compensation, and workflow versioning.
2. Context and evidence service
The context layer retrieves operational evidence from approved systems:
- metrics, logs, and traces;
- deployment and CI/CD history;
- infrastructure and configuration changes;
- feature-flag activity;
- cloud audit events;
- database and queue health;
- service catalog ownership;
- runbooks and architecture documentation;
- previous incidents and postmortems.
Do not send entire log streams or unrestricted production data to a model. Query by incident scope, time window, service, tenant classification, and data policy. Summarize only after retaining links to the original evidence.
Every claim in the agent's incident report should identify its evidence source and observation time. “Checkout latency increased after deployment 1842” is useful only when responders can inspect the trace, metric, and deployment record behind it.
3. Reasoning and hypothesis loop
The reasoning layer should produce multiple ranked hypotheses rather than one confident conclusion. Each hypothesis should include:
- supporting observations;
- contradictory evidence;
- missing information;
- proposed diagnostic query;
- expected result if the hypothesis is correct;
- risk of the diagnostic action.
This makes the agent's work reviewable. It also reduces anchoring on the first plausible explanation.
The loop should have explicit budgets for model calls, tool calls, elapsed time, and retrieved data. An incident agent that can investigate forever can increase cost and delay escalation.
4. Policy and authorization gateway
All tools should sit behind a gateway that enforces policy independently of the model.
The gateway should validate:
- agent workload identity;
- initiating user and incident context;
- environment and service scope;
- tool and operation;
- parameter constraints;
- approval requirements;
- rate and cost limits;
- maintenance windows;
- separation-of-duties rules.
The model must not receive raw cloud credentials, Kubernetes administrator tokens, SSH keys, or database passwords. The gateway holds short-lived credentials and executes only policy-valid operations.
Our guides to workload identity and MCP security explain the identity and tool-boundary controls needed for agent runtimes.
5. Deterministic executor
Approved changes should be translated into a typed command or workflow, not pasted into a shell.
For example:
{
"operation": "rollback_deployment",
"service": "checkout-api",
"environment": "production",
"from_revision": "1842",
"to_revision": "1839",
"incident_id": "INC-2741",
"approval_id": "APR-9183"
}
The executor validates the schema, verifies current state, applies an idempotency key, records the exact request, performs the operation, and returns structured results.
Avoid a generic run_shell(command) tool. It creates an enormous action surface, makes policy difficult, and allows prompt content to become executable input.
6. Verification and rollback
Execution is not success. Every remediation needs a verification contract.
A rollback workflow might require:
- deployment status is healthy;
- error rate returns below a threshold for ten minutes;
- latency and saturation remain within bounds;
- synthetic transactions succeed;
- no secondary service degrades;
- the incident timeline records the result.
If verification fails, the workflow should stop, escalate, or execute a predefined compensation. The model may interpret evidence, but success criteria should be machine-readable whenever possible.
7. Audit and observability
Record the complete chain:
- trigger and initiating identity;
- context retrieved;
- model and prompt version;
- hypotheses and recommendations;
- tools requested and policy decisions;
- approvals and approvers;
- exact operations executed;
- before-and-after telemetry;
- rollback or escalation;
- token, tool, and infrastructure cost.
Agent traces need correlation with normal service telemetry. The architecture in our OpenTelemetry production guide can connect agent decisions to downstream API calls and production effects without creating uncontrolled cardinality.
Use an autonomy ladder
Autonomy should be earned by workflow and risk class, not granted to the agent as a whole.
Level 0: knowledge assistant
The agent answers questions from runbooks, service catalogs, postmortems, and architecture documents. It has no live production access.
This level is useful for onboarding and incident preparation, but stale documentation can produce dangerous confidence. Responses should show document version and ownership.
Level 1: read-only investigator
The agent can query approved telemetry and change history. It builds timelines, suggests hypotheses, and recommends diagnostic steps.
This is the best starting point for most teams because it provides operational value without mutation authority.
Level 2: supervised operator
The agent prepares a typed action plan. A qualified human reviews scope, parameters, predicted impact, verification, and rollback before execution.
Approval must apply to the exact operation. “Allow the agent to fix checkout” is too broad; “rollback checkout-api from revision 1842 to 1839” is reviewable.
Level 3: bounded automation
The agent may execute a small set of reversible, low-risk operations within strict policy. Examples include restarting one unhealthy stateless replica, pausing a known queue consumer, or reverting a feature flag within a predefined window.
Each operation needs tested limits, automatic verification, rollback, and immediate escalation on unexpected state.
Level 4: broader autonomous remediation
This level requires strong evidence from lower levels, mature platform controls, high-quality simulations, and continuous review. It should remain rare for high-impact systems.
Do not convert an operation from supervised to autonomous because the model appears more capable. Promote it when measured workflow performance, failure containment, and rollback reliability meet an explicit standard.
Read-only is a policy, not a database permission
An apparently read-only operation can still be expensive or disruptive.
Examples include:
- unbounded log queries that overload a cluster;
- high-cardinality metric queries that consume large resources;
- database scans against a production primary;
- repeated cloud inventory calls that trigger throttling;
- retrieval of secrets or personal data through logs;
- access to another tenant's telemetry.
Read tools need scoped time ranges, result limits, query templates, tenant enforcement, redaction, caching, and cost budgets.
Prefer purpose-built operations such as get_error_rate(service, window) or list_recent_deployments(service) over unrestricted SQL, PromQL, LogQL, or shell access. Advanced responders can retain direct tools outside the agent path.
Human approval must be meaningful
A confirmation button is not a control if the reviewer cannot understand the proposed change.
An approval request should show:
- current incident severity and service impact;
- exact resource and environment;
- proposed operation and parameters;
- evidence supporting the action;
- predicted benefit and potential blast radius;
- validation checks;
- rollback plan;
- credential and policy under which execution will occur;
- expiry time for the approval.
Approvals should expire when relevant state changes. If a new deployment occurs after approval, the original rollback plan may no longer be valid.
For sensitive operations, require two-person approval or an approver independent from the workflow owner. Emergency access should be time-bound and reviewed after use.
Prompt injection is an operations risk
Production systems contain untrusted text: log messages, ticket descriptions, commit messages, customer input, repository files, dashboard annotations, and vendor responses.
An attacker or accidental string can instruct the agent to ignore policy, reveal data, or invoke a dangerous tool. Treat all retrieved content as data, never as trusted instructions.
Defenses include:
- separate trusted system policy from retrieved evidence;
- label evidence by source and trust level;
- exclude secrets and unnecessary user content;
- enforce authorization outside the model;
- require typed tool parameters;
- validate resource ownership and environment server-side;
- restrict outbound network destinations;
- sandbox code and query execution;
- scan proposed actions for policy violations;
- require approval for sensitive operations regardless of model reasoning.
Prompt-injection resistance is not solved by a stronger system prompt. The security boundary must remain valid even when the model proposes the wrong action.
Build tools around operational contracts
A good tool has a narrow purpose, typed input, bounded output, clear authorization, and predictable failure modes.
For a deployment tool, define:
- which services and environments it can access;
- valid revision formats;
- whether it can deploy, rollback, or only inspect;
- concurrency and rate limits;
- preconditions such as active incident or approved change;
- idempotency behavior;
- timeout and retry behavior;
- verification metrics;
- audit fields;
- compensation when partially complete.
Return structured errors such as REVISION_NOT_FOUND, APPROVAL_EXPIRED, or STATE_CHANGED instead of large free-form command output. The agent can reason about the error without parsing terminal noise.
Tool descriptions should not be the only source of policy. Descriptions help the model choose correctly; the executor must still enforce every constraint.
Incident memory without contaminated truth
Agents need memory, but not every prior response should become trusted knowledge.
Separate memory into:
- authoritative state: service catalog, ownership, current configuration, policies;
- observations: immutable telemetry and events with timestamps;
- case history: incident timelines, approved actions, and outcomes;
- derived knowledge: summaries, hypotheses, embeddings, and model-generated notes.
Derived knowledge must retain provenance and should not silently overwrite authoritative state. A previous agent's incorrect diagnosis should not become a fact in the next incident.
Review postmortems before indexing them, apply retention and access policy, and remove sensitive customer data. Our context engineering guide covers retrieval boundaries, memory lifecycle, and evaluation in more detail.
Evaluate the system before production authority
Generic language-model benchmarks do not measure operational safety. Build an evaluation set from your environment.
Use sanitized historical incidents, replay environments, game days, and synthetic failure injection. Include routine incidents and adversarial cases:
- misleading alert correlation;
- stale runbook instructions;
- simultaneous deployments;
- partial telemetry outage;
- prompt injection in logs or tickets;
- cross-tenant data exposure attempt;
- tool timeout after partial execution;
- an approval that expires after state changes;
- a remediation that improves one SLI but harms another.
Measure:
- evidence retrieval precision and completeness;
- time to useful hypothesis;
- hypothesis ranking quality;
- unsupported-claim rate;
- correct tool selection and parameters;
- policy-denial rate and false denials;
- approval quality;
- remediation success and rollback success;
- escalation timing;
- token, query, and infrastructure cost.
Test the full workflow, not only the final answer. A correct recommendation produced from unauthorized data or followed by an unsafe tool call is still a failed system.
Common failure patterns
Giving the model administrator credentials
This collapses reasoning and authority into one component. Use short-lived workload identity and a policy-enforcing tool gateway.
One general-purpose operations tool
A shell or unrestricted API proxy makes permissions too broad and audit too vague. Build narrow, typed operations.
Automating before establishing runbooks
If responders cannot define preconditions, execution, verification, and rollback, the agent cannot infer a reliable operational contract from scattered documents.
Treating summaries as evidence
Every important conclusion should link to source telemetry and time. Summaries can omit the exception that changes the decision.
No durable workflow state
Long incidents, approvals, retries, and handoffs cannot depend on one model session. Store state outside the model.
Approvals without exact scope
Approval should bind to a specific operation and current state, then expire.
Measuring only mean time to resolution
A faster agent that causes more secondary failures is not an improvement. Track false actions, rollback, policy violations, and responder trust.
Skipping incident review for the agent itself
When the agent contributes to a failure, preserve its context, tool calls, policy decisions, and model version. Review it like any other production component.
A practical adoption roadmap
Phase 1: map incidents and operational authority
Identify frequent incident classes, current diagnostic steps, owners, credentials, approvals, high-risk actions, and missing runbooks. Select one bounded service or workflow.
Phase 2: build read-only investigation
Connect the service catalog, deployment history, and a limited telemetry surface. Require citations to evidence and compare agent timelines with experienced responders.
Phase 3: introduce structured recommendations
Have the agent produce typed action plans with preconditions, risk, verification, and rollback. Humans continue execution through existing systems.
Phase 4: add supervised execution
Place a policy gateway and deterministic executor behind exact approvals. Start with reversible operations and verify every result automatically.
Phase 5: automate bounded low-risk actions
Promote individual operations only after replay tests and production evidence meet thresholds. Keep kill switches, rate limits, and escalation.
Phase 6: optimize from measured outcomes
Review failed hypotheses, missing context, unnecessary queries, approval friction, policy denials, costs, and responder feedback. Improve tools and operational data before changing models.
The agent should reduce cognitive load without becoming the control plane
AI agents can make DevOps and SRE workflows faster by assembling context, ranking hypotheses, preparing actions, and validating outcomes. The largest gains often come before autonomous remediation: better triage, complete timelines, evidence-linked recommendations, and consistent runbook execution.
Production safety depends on architecture around the model. Identity, policy, typed tools, durable state, approvals, deterministic execution, verification, rollback, and audit must continue to work when the model is uncertain or wrong.
BoundLayer designs and implements AI-assisted operations platforms, incident automation, internal tools, observability, cloud controls, and durable workflows. We can assess operational toil, select a bounded first use case, build the agent and tool gateway, integrate existing DevOps systems, and introduce production authority only where evidence supports it.
Related engineering articles
OpenTelemetry in Production: Observability Architecture for Traces, Metrics, Logs, and Cost Control
A practical guide to production OpenTelemetry architecture, semantic conventions, context propagation, sampling, cardinality, Collector reliability, SLOs, security, and cost control.
Internal Developer Platforms: How to Build Self-Service Infrastructure Developers Actually Use
A practical guide to internal developer platforms, golden paths, self-service infrastructure, Backstage, policy, observability, FinOps, AI agents, and platform adoption.
Zero-Downtime PostgreSQL Migrations: A Production Playbook for Safe Schema Changes
A practical guide to safe PostgreSQL schema changes with expand-contract, lock timeouts, concurrent indexes, validated constraints, batched backfills, and rollback planning.
Planning an AI-assisted operations workflow?
We design and implement production AI agents, incident automation, policy-controlled tool gateways, observability, approval workflows, and safe remediation for cloud systems.