Agent in Production

Infrastructure-as-Code Tools That Natively Treat AI Agents as Declarative Config

Declaring agent permissions in Git only matters if enforced before runs.

· 9 min read · Updated
Cover illustration for “Infrastructure-as-Code Tools That Natively Treat AI Agents as Declarative Config”
Agent-as-Code Patterns · November 8, 2026 · 9 min read · 1,954 words

Agents-as-code means defining AI coding agents’ identity, permissions, tools, and execution boundaries in YAML or similar files stored in Git, reviewed through pull requests, and enforced before execution. Infrastructure-as-Code tools that natively treat AI agents as declarative config extend familiar governance to autonomous software. The decisive property is not YAML support alone, but whether version control, scoped permissions, review, and drift reconciliation govern what the agent can do.

How the abstraction ladder reached agents

With manual provisioning, a person had to remember the intended state while clicks and commands changed the system. Infrastructure-as-Code moved that state into files. Pulumi’s IaC overview describes the distinction as declaring the desired end state and letting a deterministic engine handle the changes. Terraform HCL, CloudFormation YAML, and Pulumi programs make infrastructure reviewable, while a plan previews changes before application.

Policy-as-Code extended that pattern to governance rules enforced at plan time. Environments-as-Code then bundled policy and infrastructure into reusable blueprints. The progression reduced dependence on tribal knowledge and runtime state without changing the assumption that people authored the logic and infrastructure executed it passively.

Agents break that assumption because they observe state, evaluate context, and make decisions autonomously. Their logic is distributed across the agent, its tools, and its policy boundaries. That distribution requires an explicit authorization boundary. If permissions exist only in runtime settings or inherited credentials, reviewers cannot read the agent’s permitted scope in the same way they read an infrastructure change.

How do AI agent definitions in Git become enforceable declarative config?

An agent qualifies as declarative config when files express its identity, permissions, tool access, sandbox constraints, and behavioral boundaries. Those files must support review before execution. OpenShell YAML policies scope filesystem, network, process, and inference controls, while MCP server configurations identify external tools and APIs. Repository-root AGENTS.md files encode conventions, build commands, and off-limits directories that agents read on each run, while tool definitions specify available actions.

Instructions describe expected behavior, while security policies constrain execution. Committing both to Git makes changes visible, but the declarative governance model also requires enforceable controls before the agent runs. A readable instruction file is not, by itself, a security boundary.

The Terraform analogy makes the distinction concrete. Before IaC, an open security group was part of the deployed state. With IaC, its declaration can reveal the vulnerability before deployment. An agent policy granting filesystem-wide write access or wildcard network access exposes the same opportunity for pre-run inspection. Merely deploying an agent binary to a VM, injecting a long-lived API key, or editing a prompt in a UI without Git history does not provide that governance.

The governance primitives IaC established that agents now need

Version control gives every permission change an author, a timestamp, and a reviewable diff. Pull-request review makes that change subject to approval, while static analysis can catch unsafe declarations before deployment. Scoped permissions define the credential surface explicitly rather than inheriting whatever the host happens to expose.

Completion alone does not establish correct behavior. An agent can finish its task while exceeding its authorized scope, so observing the result cannot replace pre-run enforcement. Runtime observation remains necessary because execution may diverge from the declared boundary. Drift detection identifies that divergence, while the configuration history records what the agent was authorized to do at a particular time.

This distinction changes the purpose of agent configuration. It is not simply a convenient way to launch software. It becomes an auditable contract between the agent and the organization operating it. Engineering teams already have processes for reviewing, testing, and enforcing declarative files, so agents-as-code lets them apply that knowledge directly.

IaC tools that have added native agent support

Pulumi extends its infrastructure automation with Pulumi Neo, an AI agent for executing, governing, and optimizing complex cloud infrastructure automation with configurable human-in-the-loop controls. Pulumi supports TypeScript, JavaScript, Python, Go, C# (.NET), Java, YAML, and HCL. Its general-purpose language support gives agents testable, importable abstractions.

Terraform and OpenTofu occupy a different position. OpenTofu is the open-source fork of Terraform, and both provide declarative infrastructure on which reconciliation agents can operate. Their role as a substrate should not be confused with a complete agent definition format. The NSync case below demonstrates agents updating IaC, rather than Terraform itself declaring every aspect of agent behavior, which is the gap Ellipsis, a cloud agent platform that runs agents defined as config files in the repo on managed infrastructure, was built to close.

The kubernetes-sigs/agent-sandbox project provides a more direct execution object through its Sandbox CRD, whose apiVersion is agents.x-k8s.io/v1beta1. The agent image is a swappable field in a declared, versioned object reconciled by a controller. Isolation is optional and delegated through Kubernetes RuntimeClass to runtimes such as gVisor or Kata Containers. The declaration governs the sandbox without making low-level isolation an intrinsic property of the CRD.

Encore provides a related build-time boundary for agent-authored applications. It validates resource declarations at build time, so a misnamed topic or unresolvable declaration produces a build error. Sizing, networking, and backups are configured per environment outside the code the agent edits. This separates application intent from infrastructure permissions.

Agent-native runtimes that expose a declarative security boundary

NVIDIA OpenShell implements declarative governance at the execution layer. Its open-source sandboxed runtime wraps autonomous agents in kernel-level isolation governed by YAML security policies. The file’s policies define allowed execution through filesystem, network, process, and inference controls.

Misconfiguration makes that distinction operationally important. Filesystem-wide write access creates an overbroad filesystem boundary, while missing network policies or wildcard hosts weaken network restrictions. Running as root expands privilege. When monitor is selected instead of enforce, the policy watches execution but does not enforce its rules. Each of these problems is in the YAML before a session starts.

CrowdStrike’s Secure-by-Design AI Blueprint embeds Falcon into OpenShell for real-time monitoring, while TrendAI adds runtime enforcement through its integration. Those controls complement policy inspection. OpenHands takes another approach by integrating native sandboxed execution, lifecycle control, model-agnostic multi-LLM routing, and built-in security analysis. These establish execution capabilities while leaving open whether every aspect of an agent can be declared entirely in YAML.

MCP configurations add a further boundary because they identify external tools and APIs, including dynamically fetched servers that can introduce supply-chain risk. Encore’s agent infrastructure guide calls for isolated environments that can be discarded after use, with scoped network access and task-scoped credentials, and keeps long-lived cloud credentials out of the agent environment. Codex keeps network access off by default in its workspace sandbox.

Drift detection applied to agent config: the NSync case

Infrastructure drift occurs when console, CLI, or SDK changes diverge from the IaC source of truth. An outdated declaration can then revert intended changes and cause misconfigurations or failures. Reconciliation must recover the intended state. That makes drift more than a comparison problem when the reason for an out-of-band change is not explicit in the configuration.

NSync, described in Automated Cloud Infrastructure-as-Code Reconciliation with AI Agents, is a research system from the University of Michigan and Amazon Web Services. It extracts drift signals from cloud API traces because changes through IaC, consoles, CLI, and SDKs ultimately invoke cloud APIs. LLMs infer high-level change intent from noisy, low-level sequences. Domain-specific context management and custom agent tooling then synthesize targeted IaC updates, supported by a knowledge base of successful reconciliation runs.

The paper evaluates NSync on five real-world Terraform projects across 372 drift scenarios. It reports pass@3 accuracy of 0.97, compared with a baseline of 0.71, and a token efficiency improvement of 1.47×. NSync cannot directly test its synthesized updates in a live environment, which reinforces the need for reviewable output.

The broader governance lesson follows from that constraint. An agent can generate a patch, a plan can preview its effect, and policy can catch mistakes before production. Applying the same discipline to agent definitions extends the lifecycle of declaration, review, application, drift detection, and reconciliation to both managed resources and the agents managing them.

Why static analysis of agent config files is the missing shift-left step

The rationale for scanning Terraform before application applies equally to agent policies. By the time an open S3 bucket is found in production, it has already been exposed. An overprivileged agent presents the same timing problem. Runtime enforcement can stop exploitation, but static analysis can find the unsafe declaration before there is an execution environment.

Traditional application security tooling does not yet cover agent configuration artifacts with comparable maturity. OpenShell policies, MCP configurations, AGENTS.md files, tool definitions, and workflow orchestration files may sit in scanned repositories without their agent-specific risks being analyzed. Repository coverage is not semantic coverage. A scanner must check whether a declaration allows tool misuse, inherits too much privilege, fetches compromised tools, or lets code run without enough sandboxing.

Regulatory pressure reinforces the need for this work. The EU AI Act’s Annex III rules for high-risk systems apply in December 2027, and NIST announced its AI Agent Standards Initiative on February 17, 2026, though final agent-specific standards are not expected before 2027 at the earliest. Earlier concept papers and RFI analyses do not remove today’s implementation gap.

What governed agent execution looks like in a production engineering org

A governed agent lifecycle begins with a reviewed declaration and proceeds into isolated execution. Each session receives credentials minted for that session and revoked when it ends. This is a target operating model. Encore’s infrastructure design and the Kubernetes sandbox model point toward that separation between an agent session and persistent infrastructure authority.

Observability then records execution with enough context for attribution. Every tool call, diff, and token is logged against a person or trigger, and OpenHands’ event log model for persistent context shows the kind of record an audit trail needs. Cost controls act before money is spent through hard caps per session, per developer, and per time period, with limits on iterations and human approval at irreversible steps.

Atlassian illustrates the reviewable work loop at enterprise scale. Jira identifies clearly defined unassigned work, delegates implementation and testing to a coding agent, and receives a pull request. Standards capabilities apply organizational coding rules across repositories, while AI Review checks changes against those standards before human review. The example shows structured inputs and outputs that people can review, but leaves open whether every execution control described above is in place.

How to evaluate whether an agent tool actually implements the declarative governance model

The first test is whether permissions, tool access, and sandbox policies can be committed, diffed, and reviewed before execution. The second is whether static analysis and pre-run enforcement can reject filesystem-wide access, wildcard network rules, and monitor-only policies. These tests distinguish reviewable authorization from a YAML wrapper around opaque execution.

The third test checks that each session gets scoped credentials that expire or are revoked when it ends, rather than inheriting long-lived ambient credentials that a compromised sandbox could expose. The fourth test is drift handling. The tool should detect divergence in runtime permissions or managed infrastructure and provide a route back to the declared source of truth.

The fifth test is whether session records support reconstruction of tool calls, diffs, token use, policy decisions, and authorization. A completion flag is not an audit trail. The sixth is whether hard budget and iteration caps prevent excess consumption. The seventh is whether irreversible actions require human sign-off independently of the agent’s assessment that they are correct.

These criteria also clarify YAML-only claims for buyers. A YAML security policy, a Kubernetes sandbox manifest, and an IaC program describe different layers, so support for one does not establish complete declarative agent governance. The next rung of the abstraction ladder is an enforceable agent boundary with a reviewable lifecycle. Teams that establish it can expand automation without surrendering the controls that made infrastructure automation governable.

Sources

  1. Automated Cloud Infrastructure-as-Code Reconciliation with AI Agents

More in Agent-as-Code Patterns