Beyond Git Worktree
Cloud AgentsLong read

Keeping Agent Behavior and Application Code in Lock-Step Across Every Commit

Versioning prompts, tools, and permissions beside your code catches drift.

· 9 min read · Updated
Cover illustration for “Keeping Agent Behavior and Application Code in Lock-Step Across Every Commit”
Cloud Agents · November 15, 2026 · 9 min read · 1,943 words

Agents-as-code means keeping agent definitions in Git with the application code they govern, then reviewing and testing both through the same change process. YAML can define a prompt-based agent, but the versioned contract must also cover its instructions, tools, permissions, budgets, and environment bindings.

Why agent behavior drifts independently of model capability

Agent behavior comes from the interaction of model weights with a harness, prompts, tool configurations, retrieval sources, memory state, and an execution environment. A change to any of those inputs can change what the agent does without changing its underlying capability. Synchronization therefore requires attention to system composition beyond model choice.

Stephanie Jarmak’s Engineering Reliable Coding Agents establishes the distinction between evaluating coding agents as models and deploying them as systems. The study places reliability in the surrounding harness, execution state, retrieval, memory and state management, permissions, review interfaces, and resource allocation. Those components shape the conditions in which the model can do useful work. Evaluating the model alone leaves those conditions untested.

That distinction changes what a commit represents. A change to application logic, a tool interface, or environment configuration is a potential behavioral change even when the agent definition has no diff. Furthermore, the same agent can follow different sequences on separate runs of the same task, so a previously successful sequence is not a fixed workflow that later runs must reproduce. Control must account for that variability. The agent must still behave within the intended boundaries against the current application, even when its model remains the same.

What actually changes agent behavior across commits

Stale instructions are one direct source of drift. Files such as CLAUDE.md, rules files, and architecture decision records encode expectations about the codebase. When application code changes but those expectations do not, the agent receives guidance that describes an earlier state. The instructions may remain readable and internally coherent while directing work toward the wrong behavior. Their validity depends on the code they describe.

Tool interfaces create a different kind of mismatch. Tool and MCP server configurations define the actions available to an agent, but a refactored API surface or renamed endpoint can break a tool call without raising a schema error. Retrieval can fail less visibly. Documentation, inline comments, and test fixtures shape the context available to the agent, and outdated context can produce plausible but wrong behavior. A valid configuration and a convincing response therefore do not establish compatibility with the current application.

Stripe’s Minions illustrate why these surfaces belong in the same engineering discussion. Stripe uses blueprints, which are workflows defined in code where a node can run deterministic code or an agent loop focused on a task. Its engineers describe agent skills interwoven with deterministic code. That composition makes the relationship between behavioral instructions and executable application behavior central to reasoning about a run.

Those surfaces also depend on the execution environment. Harness behavior, dependency versions, and runtime credential scope are behavioral inputs whose effects the agent cannot reliably compensate for. Jarmak identifies this as a dependency chain in which weaknesses in execution environments, retrieval, state management, or verification can invalidate conclusions downstream. A successful result cannot establish reliability if the conditions producing it are no longer the conditions being deployed.

Why treating agent config as a separate artifact makes drift harder to catch

Separate configuration often emerges naturally as teams adopt agents incrementally. Instructions may live in a web UI, tool settings in infrastructure state, and budget policies in a dashboard. Each place can do its job while leaving parts of the system out of the application’s commit graph. The reviewer sees the application diff but not the full change to the system that will act on it.

A prompt edited in a web UI leaves no Git history for the engineer reviewing a related API change. A separate repository may have its own history, but that history does not by itself bind the configuration change to the application commit. The same problem applies to tool authorization. Its scope can expand or contract outside the review that assesses the application, while dashboard-based budgets and permission policies remain invisible to the CI pipeline exercising the new code.

Wang et al.’s Humans are Missing from AI Coding Agent Research identifies verifiability as a core bottleneck. Agent outputs can be difficult to interpret or verify, while behavior can be hard to control or predict over time. Unversioned configuration compounds that difficulty because the reviewer cannot establish which behavioral instructions and boundaries belong to the change under review.

Calling these files “just prompts” understates their role. Instructions that govern tool access, memory scope, and decision boundaries are behavioral contracts with consequences for execution. Their review is a way to assess changes to what the application’s agent is expected and authorized to do.

How to store AI agent definitions in Git for normal code review

The practical prescription is to commit agent configuration to the same repository as the application code it governs. The versioned artifact set includes prompt and instruction files, tool and MCP server configurations, permission and credential scope declarations, budget policies, and environment bindings. Credential scope declarations describe authority rather than supplying a reason to commit credentials themselves. Together, these artifacts make the agent’s behavioral contract available in the application review. Ellipsis, a cloud agent platform that runs Claude Code and Codex on managed infrastructure rather than a bare VM with an API key, takes YAML agent definitions checked into the repository.

Microsoft Foundry’s reference implementation commits agent.yaml or prompt definition files for prompt-based agents together with tool configurations and Infrastructure as Code templates. Its tool configurations include MCP servers and REST API connectors. The versioned artifact is then promoted through environments, so the deployment process works from an identified definition.

For a repository using this pattern, the layout is conceptually straightforward. The agent definition sits in the application repository with its prompt files, tool configurations, policy declarations, and environment bindings, while code-specific guidance lives near the code it describes. The Git workflow then puts related changes in the same pull request so they can be reviewed and tested together. An application change can leave the configuration as it is. The existing contract still needs to be checked to see whether it fits.

Strict support for declarative configuration files in Git is a narrower claim than agents-as-code. Foundry provides a concrete reference pattern for versioned declarative or prompt-based definitions, but that does not establish that every agent or tool can be implemented entirely in declarative files without general-purpose code. Stripe’s blueprints illustrate a different approach based on workflows defined in code. The useful comparison is therefore between declarative definitions and code-defined workflows, with reviewability, versioned tool configuration, and environment promotion as the criteria.

How subdirectory-scoped and conditionally applied rules keep config in sync as the codebase grows

A single global configuration can become a maintenance burden as the codebase expands. Guidance for one part of the application becomes mixed with guidance for another, weakening the connection between an instruction and the code it describes. Conditional, subdirectory-scoped rules preserve that connection. They make behavioral guidance local enough to evolve with the implementation rather than requiring every change to pass through one monolithic instruction file.

Stripe applies almost all agent rules conditionally based on subdirectories. In this pattern, payment processing rules live beside payment processing code, so a pull request that changes that code brings the rules into view for review. The code and its instructions share a review boundary. Storing the files together still leaves their contents to be checked for correctness.

The pattern is familiar from other engineering configuration. Mature teams already manage lint rules, test configuration, and build policies per package rather than treating every concern as repository-wide. Agent rules fit the same mental model because they should cover the code whose behavior they describe. Local configuration is still part of the versioned system, and teams can maintain it without reading unrelated instructions.

Architecture decision records provide complementary context within that structure. Checked into the repository, they give agents the design rationale available to human reviewers. They can still become outdated. An outdated record is visible and correctable through the ordinary review process, whereas a stale prompt buried in a UI sits outside that path. Scoped rules and recorded rationale make synchronization an extension of existing engineering practice.

What evaluation gates must check at every commit that touches agent config or application code

Version control makes a behavioral change visible, but it does not establish that the change is safe or correct. CI must treat changes to agent definitions as triggers for behavioral evaluation as well as static linting. Application changes need the same treatment when they affect the agent’s operating conditions. Otherwise, the repository records the contract while the pipeline leaves its compatibility untested.

Foundry’s reference implementation has gates at pre-merge in CI and pre-promotion in CD. A single agent version moves through Dev, Test/QA, and Production. Test/QA has human-in-the-loop validation and safety evaluation, and a reviewer must approve the version before it reaches Production. This separates evaluation before accepting a change from evaluation before advancing its version into another environment. The version remains the unit of promotion.

Tool call correctness must be checked against the new API surface, budget compliance against the new configuration, and permission scope against the new credential policy. Behavioral regression checks need a task set representative of production workload. Static validity is not enough. A configuration can parse successfully while authorizing the wrong action or directing the agent toward an obsolete interface.

The gates also depend on one another. Jarmak describes execution-based evaluation, correction gates, and release tests as a dependency chain in which weaknesses early on weaken the conclusions drawn later. Wang et al. also call for thorough verification because outputs that look right can be hard to verify. Gates must therefore expose behavioral divergence as well as detect execution failure. When a version fails, versioned configuration allows rollback by switching the active version pointer to the previous agent version, the same way application rollback works.

Observability and audit trails as the feedback loop that keeps gates honest over time

Commit-time evaluation cannot establish how an agent will behave across all production runs. Persistent, attributable observability supplies the evidence needed to compare actual behavior with the reviewed configuration. That evidence must cover more than model calls and token counts. Tool invocation traces, memory read/write events, decision boundary logs, and cost attribution per session, developer, and trigger reveal the operating behavior that evaluation gates are meant to constrain.

Observability and audit trails serve different purposes. Observability traces are sampled and expire, while an audit trail must record every tool call, diff, and decision in a tamper-evident, attributable record. The two require separate implementation. A sampled trace can support investigation, but it cannot stand in for a complete account of authority and action.

When production behavior departs from the reviewed intent, attribution connects the anomaly to the change process. The audit trail makes it possible to identify the configuration version, application commit, and person or trigger that authorized the run. That connection gives the team a basis for examining both the contract and the evaluation that allowed it through. Jarmak places observability in the reliability chain precisely because weak evidence can invalidate downstream conclusions, including conclusions about whether the gates work.

Versioned definitions establish what was reviewed, evaluation gates record what was tested, and attributable production records establish what actually happened under that authority. Together, they let engineering leaders answer “what did the agent do, under what authority, and who approved it.” That is how control scales with agent use without depending on the assumption that an unchanged model will keep behaving the same way.

Sources

  1. Engineering Reliable Coding Agents: Evaluating and Operating the System Around the Model
  2. Humans are Missing from AI Coding Agent Research
Filed underCloud Agents

More in Cloud Agents