Ship the Agent as One Versioned Bundle: Prompts, Tools, Model and Policy Together
The code in an agent service is often the part that changes least. What changes often is the system prompt, a tool’s description, the model version, a threshold, and the IAM policy for a new tool. Each of those changes the agent’s behaviour as much as a code change would. In many teams they reach production by different routes: a prompt edited in an admin UI, a model alias that moved, a policy changed in the console.
That creates a specific problem. When the agent starts behaving differently, nobody can say exactly what changed, and nobody can put the previous behaviour back quickly. The fix is to treat everything that determines behaviour as one versioned unit, and deploy it through git like any other change.
The bundle
Put everything that determines the agent’s behaviour into one directory, in the repository:
agents/billing-investigator/
bundle.yaml
prompts/
system.md
examples.md
tools/
search_invoices.json # tool schemas and descriptions
issue_refund.json
policy/
role.tf # the agent's IAM role and blast-radius note
evals/
cases/*.yaml
thresholds.yamlWith a manifest that pins the choices the code reads at runtime:
# bundle.yaml
agent: billing-investigator
model:
id: YOUR_EVALUATED_MODEL_VERSION # replace with a supported, pinned identifier
max_tokens: 1024
temperature: 0
limits:
max_steps: 20
max_session_usd: 2.00
tools: [search_invoices, issue_refund]
approval:
issue_refund: { above_usd: 50 }Content-address it
The bundle’s version should be derived from its file contents and relative paths. The GNU-tooling example below assumes identical paths and filenames without newlines. Package metadata and external dependencies require their own manifest:
# GNU find/sort/sha256sum example; run from the same repository-relative path.
# Excluding evals requires recording their version separately with the release result.
find agents/billing-investigator -type f -not -path '*/evals/*' -print0 \
| LC_ALL=C sort -z \
| xargs -0 sha256sum \
| sha256sum | cut -c1-16CI builds the bundle, computes the hash, and uploads it to immutable storage: an S3 bucket with versioning and object lock, or an OCI registry. The agent loads a bundle by hash at startup, and reports that hash in every log line and trace. From then on, “what was the agent running at 14:02?” has an exact answer.
Promote through environments with a pointer
Each environment has a pointer to the bundle hash it should run, kept in the same repository:
# environments/prod.yaml
billing-investigator: 3f9a1c07be52d8e4The flow:
- A PR changes something in the bundle. CI computes the new hash and runs the eval suite against it, with the results posted to the PR.
- After merge, the staging pointer is updated automatically to the new hash.
- Promotion to production is a PR that changes one line in
prod.yaml. It carries the eval results and needs an approval. - The runtime watches its environment’s pointer and loads the new bundle for new sessions, leaving sessions already in progress on their original bundle.
Reverting that pointer selects the previous bundle for new sessions. It does not undo completed actions, database migrations, external state or separately applied IAM changes. Keep compatible bundles available and test rollback against the current schema and permissions before calling it a recovery plan.
For gradual rollout, the pointer can hold two hashes and a traffic split. Compare the two on tool-call errors, escalations, blocked actions and cost per session before moving everything over.
The IAM piece
The IAM policy in policy/ is part of the bundle’s review but not its runtime. It’s applied by Terraform through its own pipeline, because the role must exist before the agent uses it. Keep them linked:
- a bundle that adds a tool must include the policy change that permits it, in the same PR;
- CI can compare a declared tool-to-permission manifest with reviewed policy changes. A complete AWS authorization proof is more involved: conditions, resource policies, boundaries and organization policies must also be considered. Do not claim a text comparison proves the effective permissions.
The second check is the one that keeps permissions from quietly piling up after tools are removed.
Detect drift
GitOps only works if the running system actually matches git. Two checks:
- Every agent reports its bundle hash. Alert if any running instance reports a hash that isn’t the one its environment’s pointer names, beyond a short rollout window.
- Nothing else can change behaviour. No admin UI that edits prompts in production, no model aliases, no console access to the agent’s role for day-to-day work. If an emergency change is needed, it goes through the same pointer, with the review done afterwards.
Where this stops
This records the reviewed inputs and makes compatible bundle selection reversible. It does not reproduce a nondeterministic model response or reverse an external action. It doesn’t make a change good. That’s the job of the eval suite that gates each bundle, and of the gradual rollout. The upstream model provider can still change behaviour behind a dated model ID, rarely but not never. Keep watching production metrics even when the hash hasn’t changed.