The Model Proposes. The Harness Decides.
Deployment is where the harness becomes the policy boundary, and the platform is a choice you can change later.

AI agent harness deployment puts a policy boundary between the model and every system it can touch, before you pick a platform.
Picking a hosted agent platform does not make a deployed agent safe. Identity, hooks, and the sandbox decide what the model is allowed to do.
In this article: Each factory stage needs its own identity, sandbox, and stop condition. Hooks beat rules that live only in a prompt. GitHub Actions, Microsoft Foundry, Amazon Bedrock AgentCore, Anthropic's managed agents, Kubernetes, and a homegrown runtime are options, not a recommendation.
A ticket reviewer, a sandboxed build loop, and a read-only diagnostic agent each have to run somewhere. Someone still decides the identity, the permissions, and the stop. Those choices are where harness engineering becomes infrastructure. In the maturity model, the harness is level 3: the runtime and policy boundary between the model and everything it can touch. Get the harness right and the platform is convenience. Get it wrong and no platform will save you. Every loop in the factory runs inside one.
The harness is the policy boundary
A harness sits between the model and every system it can touch. The model proposes. The harness decides. Output that skips that line is a script, not a harness. The harness as the policy boundary is ordinary platform engineering for an actor that follows bad instructions and never gets tired of trying.


Six controls make up the harness. The Control column names each one. The What it does column says what the control enforces. The What breaks without it column says what goes wrong when the control is missing.
- Identity: each stage runs as its own service identity, never a borrowed human token. Without it, you cannot tell which agent acted, and agents inherit human rights.
- Permissions and approvals: each stage gets least privilege, and named people approve merges and releases. Without them, an agent approves its own work, or reaches production.
- Hooks: deterministic code runs before and after tool calls, and at the end of a run. Without them, rules live only in prompts, and the model can talk around them.
- Sandbox: every run gets a fresh isolated environment that is destroyed afterward. Without it, state leaks between runs, and one compromised run reaches the next.
- Network egress rules: the sandbox reaches only the registries and services it needs. Without them, one prompt injection can send private data anywhere.
- Tracing and budget: every step is recorded, and every run has a time and money limit. Without them, failures stay silent, and the bill arrives before the merge.
The harness moves the score, with the model held fixed. SWE-agent's designed interface (a capped search, a file viewer that shows 100 lines at a time, and a linter that rejects broken edits) solved 10.7 points more SWE-bench tasks than a plain shell, a 64% relative increase (SWE-agent). Epoch AI found that switching the scaffold alone moves SWE-bench Verified scores by up to 11% for GPT-5 and 15% for another model. LangChain raised its coding agent's Terminal Bench 2.0 score by 13.7 points by changing only the harness. In April 2026, the same Claude model scored 65.4% on its own and 81.8% inside a multi-agent harness. A benchmark score belongs to a model inside a harness. In this framing, the model is the CPU and the harness is the operating system.
In 1947, Paul Fitts and R. E. Jones traced hundreds of so-called pilot errors for the US Air Force to the instruments, not the pilots. Software engineers call that mechanical sympathy: when the operator keeps making the same mistake, the environment is the variable.
Hooks the model cannot argue with
Permissions ask the model to behave. Hooks do not ask. A hook is code that runs before a tool call, after it, at session start, and before a run may finish. The model cannot persuade it.


Hooks attach at four points in a run. The Hook point column says when the hook fires. The Example rule column gives one rule a hook at that point can enforce. Two points carry two examples each.
- Before a tool call, a hook blocks shell commands that touch production hosts, push to protected branches, or read secret files.
- Before a tool call, a hook can also refuse to edit tests and code in the same change on a high-tier ticket.
- After a file write, a hook runs the formatter, the linter, and the type checker, and returns the errors to the agent.
- At session start, a hook loads the ticket, the relevant decisions, and the stage's budget into context.
- Before the run ends, a hook refuses to stop until the tests pass, or until the run hands back to a person with a written reason.
- Before the run ends, a hook also writes the evidence record and the trace, whatever the outcome.
A stop hook turns "the agent says it is done" into "the checks say it is done," and a hook that always writes the record leaves a trail when a run fails halfway. A recipe agent can be told about a life-threatening shellfish allergy and, thirty turns later, still choose a sauce that contains shellfish, because the fact sat mid-window. A rule file is advice. An ingredient check in a hook is enforcement. The same wrapper can cap a ten-thousand-row query or replace a megabyte of logs with a summary and a pointer.
Agents differ when a hook blocks or fails. As each tool's own documentation stated in November 2026:

Six coding agents handle hooks differently. The Coding agent column names the tool. The How a hook blocks column says what signal a hook uses to block a call. The If the hook errors column records what each tool documents for that case.
- Claude Code: exit code 2 blocks a PreToolUse call, and engineers cannot turn off managed settings.
- Codex: a deny, or exit code 2, blocks the call, but an error, timeout, or malformed response can let the tool run.
- GitHub Copilot cloud agent: preToolUse blocks on exit code 2. It fails closed, and treats "ask" as deny when no user is present.
- Cursor: exit code 2 blocks, for compatibility with Claude Code. Its run modes are best-effort guardrails, not a hard boundary.
- Gemini CLI: exit code 2 blocks, and the agent runs inside a documented sandbox.
- OpenCode: only plugin code can block, and any deny denies.
Know how your tool behaves when the hook itself errors. Version hook code, review it, and treat a change as high tier. Behavior changes monthly, so date what you read.
Work that outlives a session
Split the initializer from the worker. Anthropic's long-running harness uses two agents (Effective harnesses for long-running agents). The initializer runs once and writes a setup script, a progress file, and an initial commit. The worker repeats: one increment, a commit, an updated progress file. A restart does not re-run setup.
Verify in layers, with bounded recovery. One zero-trust design checks the repository state, that the deployment matches it, and that the running system behaves (a zero-trust agent harness). Recovery runs a fixed number of times, then stops in a recorded failure a person sees. One framework documents it so far. Copy the pattern even without the numbers.
Make execution durable. Resume from the last good checkpoint after a deploy, a restart, or an outage. Durability does not stop errors from compounding, so it complements the checks. Temporal provides it, and several managed platforms provide a version of it.
Climb only as far as the loop needs
Design the loop first and the runtime second.

- A CI action on a repository event. A plugin on an issue or pull request, with the CI log as the audit trail. Most stages stay here for months.
- A container behind a webhook. More time, memory, tools, or control flow than CI allows, in a sandbox on an SDK such as the Claude Agent SDK or LangChain Deep Agents.
- A durable runtime. The stage must survive restarts or hold state for hours or days.


Six runtime options can host a stage. The Option column names each one. The What it gives you column lists what the platform provides. The What you still own column lists what stays your job. The Fits when column says when to pick it.
- GitHub Actions (or another CI) gives you event triggers, ephemeral runners, scoped secrets, and an audit log you already have. You still own sandbox hardening, egress, and budgets. It fits when you are starting, or when the stage is short and event-driven.
- Microsoft Foundry is Azure's build, deploy, and eval platform, with Azure identity and networking. You still own the loop, the hooks, and evals tied to your work. It fits when identity and data already live on Azure.
- Amazon Bedrock AgentCore gives you an AWS runtime, memory, identity, a tool gateway, and observability. You still own the loop, the hooks, and evals tied to your work. It fits when identity and data already live on AWS.
- Anthropic's managed agents give you a hosted harness and a managed sandbox for Claude. You still own triggers, permissions into your systems, and evals. They fit when you do not want to run the harness, and Claude is the model.
- Kubernetes gives you a pod per run, network policies, your secrets manager, and sandboxed runtimes. You still own the harness itself. It fits when you have a platform team and strict network or residency rules.
- Build your own with an agent SDK in containers plus a workflow engine such as Temporal. You own the harness, and you get the most flexibility. It fits when you need custom durability, scheduling, or cross-cloud runs.
The platform is a substrate. The loop stays yours: trigger, stop condition, checker, budget, and hooks. None of these platforms is safe by default. If you can move a stage between options without rewriting the loop, you designed the loop first.
Who wakes the loop is a second ladder: by hand, on a schedule, on a CI event, then on a webhook. Headless mode takes one prompt and returns structured output. Prefer an event to a timer, because a timer that fires when nothing changed spends tokens to learn nothing. Three guards: ignore your own output, one run per item, and a stable work ID so a retry cannot write twice.
Approval is a state, not a hope. On a high-risk action, save state, pause where the team can see it, and resume only when an authorized person approves.

Security that does not depend on the model
An agent is dangerous when it has private data, untrusted content, and an external channel all at once. Break that combination per stage.
- Treat every input as untrusted. Tickets, pull request text, review comments, logs, and fetched pages are data, not instructions. Prompt injection through them is a known, exploited attack on CI-hosted agents.
- Give each stage only two of the three. The ticket reviewer reads untrusted text, holds no secrets, and cannot reach the network. The diagnostic agent reads production logs and can only write a draft ticket.
- Keep production credentials out of every sandbox. Short-lived tokens per run. Never a long-lived key an agent can read.
- Agent identities never approve a merge, a change record, or a release. Branch protection enforces it.
- Mask before you trace. Redact at the source, before a trace leaves your environment or reaches a model.
- Block agent-triggers-agent chains, or one loop can start a billing spiral.
AI-assisted code fails security tests at a stubborn rate even as it gets more correct, and developers are often more confident in insecure AI-written code than in their own. The controls have to hold no matter who, or what, wrote the change.
In Anthropic's internal use, sandboxing cut permission prompts by 84%, a vendor measurement rather than a controlled study (Beyond permission prompts). Constant approval produces approval fatigue: people stop reading what they approve.
One feature, every rung
On an admin audit export, reviewers ran as read-only CI actions. Build workers ran in fresh sandboxes with no production credentials, and a stop hook caught a large-workspace timeout before any pull request existed. A read-only diagnostic session saw a support line asking to raise an export limit and changed nothing, because its identity could not. A later multi-repository migration left CI for a durable runtime. The loop did not change. Its wiring did.
Do this today
- Write one page before you choose a platform: identities, read and write rights, egress, budgets, mandatory hooks, and who approves what.
- Run a ticket reviewer and an advisory pull request reviewer as CI actions, each on its own read-only app identity.
- Add a stop hook that requires passing checks, and a hook that always writes the trace and the evidence record.
- Leave CI only when you can name the limit a stage hit.
- Place the stage where your identity and data already live.
The platform is a convenience
A hosted runtime can hand you compute and traces. It cannot hand you the loop. Trigger, stop condition, checker, budget, and hooks stay yours on every row above, and none of those rows is a safe default. When an agent keeps making the same mistake, change the harness. Where does your first agent run today, and what identity does it run as?
This is Part 13 of "AI Software Factory Series," a 17-part guide to building an AI software factory with human gates.