Skip to content

Agent Infrastructure Is a Boundary Problem

#agentic-ai #mcp #agent-sandboxing #cost-control #tool-security #agent-reliability

A $6,531 AWS bill and the boundary problem ​

The bill was $6,531.30. An AI agent asked to build an index of DN42, a hobbyist BGP network where people practice internet routing, provisioned five m8g.12xlarge instances and waited for its pull request to merge.

Every API call it made was valid. It picked real instance types, wrote BGP configs that parsed, and drew up a load-balanced anycast design with per-node sessions. The technical work held together. The ceiling was missing: no spend limit, no approval gate on provisioning, no control asking what "run a network scan" actually granted. The operator ended up asking the DN42 community for donations.

That story is the cleanest illustration of where agentic infrastructure problems live. They sit in the boundary layers around the model: who can sign up, what a credential reaches, how much compute a waiting agent reserves, and whether anyone reviews a new tool before it ships.

Four surfaces, one theme. Let me take them in the order a new agent hits them.

Key numbers ​

MetricValue
Final AWS bill for the DN42 scan$6,531.30
Instances provisioned5 × m8g.12xlarge, 48 vCPU and 192 GiB each
Aggregate scan bandwidth claimed100 Gbps
Typical DN42 participant uplink100 Mbps to 1 Gbps, with a traffic cap
Production tickets in one published scar ledger375
Repeat code regressions across those tickets0.0%
Repeat harness/process failures9.87% (37 of 375)
Input token reduction from lazy tool loading58.2% to 92.8%
Instruction-canary runs completed30 of 30

Getting an agent an account without handing over your keys ​

AWS now ships a flow that solves the first hop. aws signup --remote prints a URL, you open it on your own device, sign in with a login you already own, and paste a code back into the terminal. The agent never sees your password. It gets a credential good for 12 hours, renewing itself for 90 days before another browser step.

No root user. No access keys on a laptop. No hand-rolled first IAM user.

I ran this end to end from a cloud session with no browser. The agent fetched the setup instructions, asked four questions, backgrounded the signup command, and waited. I clicked through on my phone. It verified credentials with sts get-caller-identity, pointed the MCP server at the new profile, and wrote rules into CLAUDE.md. Twenty-five of 126 catalog skills installed with auto-updates on.

Two things it did on the first deploy changed my read on the pattern.

It checked the money before building. A sandboxed boto3 call asked for the plan state and got back Free tier, active, $100 credit intact, six months of runway. Then it said out loud that the deployment would barely touch it.

It skipped AWS WAF on purpose, because WAF runs $5 to $6 a month, and told me why before offering to add it later. A beginner would not have known that was a decision.

The trade is real. The project account gets a service subset: no Marketplace, no opt-in regions, no savings plans, no net terms. Permissions are coarse, since everything in a project can reach everything else in that project. HIPAA and FedRAMP workloads belong on the advanced sign-up path. The spend limit only exists after you upgrade from free tier, and that upgrade covers every project at once and doesn't reverse. If an agent is going to loop on a failing deploy at 3 AM, that limit is the difference between a bad night and the DN42 story.

Quick take: the engineering that matters in agentic infrastructure lives in the boundary layers around the model, in credentials, quotas, sandboxes, and tool authority, and almost never in the prompt.

Suspend the machine, keep the workspace ​

Compute is the second surface. One agent per VM works for ten users and gets expensive at a million.

An agent runs for a few seconds, then waits: on a model call, an external API, a human approval. A dedicated VM or Pod keeps its memory and CPU reserved through every one of those waits. You pay the same for a waiting machine as a busy one, so the bill scales with signups while the work scales with concurrent turns.

Agent Substrate hit 1.0 on November 5 and separates the workspace from the machine. Three parts: actors hold memory, files, and identity with no machine attached; workers are pre-started Pods in a warm pool, each hosting many awake actors in separate gVisor sandboxes or Cloud Hypervisor microVMs; gateways handle ingress routing and outbound credential injection.

When a turn ends, your orchestrator calls SuspendActor. Memory and files land on local disk and in Cloud Storage, and the worker slot frees up. A request inside 30 minutes returns to the same node from local cache. After that it wakes on any worker with room, under a second, from object storage. Memory snapshot restore beats the 3 to 5 seconds a GKE Pod snapshot takes.

Sizing is one line of arithmetic. Peak running actors equals total actors times the active fraction times a burst factor. Eight percent of 1,000 actors at 2x burst is 160. If a worker fits 50 agents, divide 160 by 80% of 50, which is 40, and you need four workers. A thousand actors, 996 of them asleep, four machines. The README shows about 250 stateful actors across eight worker pods.

What I'd stress test is what survives a suspend. Sub-second resume means checkpoint and restore, and process trees are the historically brutal part: open sockets, a dev server holding a port, a file mid-write. After a wake, database and MCP sessions need to reconnect, and wake time grows with snapshot size, which is why large workspaces belong on a Filestore volume. A benchmark that diffs the process tree, listening ports, and file descriptor table against the snapshot would make the 1.0 claim falsifiable for agents that run things rather than chat.

Your tool registry is API surface ​

Most review effort goes into the model. Can it be jailbroken, will it follow an instruction buried in a scraped page. Those are real questions that stop one step too early. The model picks a tool. The tool carries the authority.

In a demo the agent has three tools and none can hurt anyone. In production the list grows one PR at a time. Someone adds create_ticket. Someone adds run_sql for internal analytics. A third person swaps a read-only GitHub token for full repo scope because the agent needs to open PRs now. No route file changed, so none of it got the review a new public endpoint would get.

Four questions per tool. What kind of action is it: read, write, execute, or external trigger like email, payment, deploy. Whose identity does it run as: the user's delegated identity, a shared service account, or the agent's own credential with org-wide scope. What data can it reach, as opposed to what it's meant to reach. And where approval is enforced, in the tool layer or in the system prompt.

If the answer to the last one lives only in the prompt, you have a polite request for an approval step.

Three failure shapes repeat. A read-only lookup_customer(query) tool that calls an internal admin endpoint accepting arbitrary filters, so a read tool paginates through every account in the system. An update_order_status that looks like a single row write and also fires a webhook and kicks off a refund workflow, so reviewers approved a database write and shipped a refund button. Identity drift: a read-scoped token picking up write on two repos, Slack admin, and a cloud role attached during an incident, none of it alarming alone.

The fix is declaring authority in the tool definition so a change shows in the diff. Flip requires_approval to false, or identity from user_delegated to service_admin, and CI blocks the merge until a named reviewer approves with a justification attached to the registry entry. Then snapshot effective permissions at the provider and compare against both the registry and the previous snapshot, because a review-time diff only catches what passed through a PR.

Where the control actually lives ​

MCP gateways are the layer teams reach for once the second agent and the fifth server show up: aggregation behind one endpoint, authentication on both sides, per-caller tool filtering, logging, and context cost control.

Server-level access answers the wrong question. Letting an agent connect to the GitHub MCP server is coarse. The real question is which tools on that server it can call: read tickets yes, close tickets maybe, delete a repository no, call the production variant only with approval.

If you needStart with
One self-hosted gateway for MCP, model traffic, and A2A, with VPC and air-gapped optionsBifrost
MCP governed inside existing Kong API managementKong AI Gateway
An open-source Python proxy you operate yourselfLiteLLM
Fully managed, AWS-native tool exposureBedrock AgentCore Gateway
Federation across MCP, REST, and gRPC servicesIBM ContextForge
MCP servers isolated in containers for developersDocker MCP Gateway

The number that sold me on context control: one gateway's lazy tool loading took a catalog from 96 tools across 6 servers to 508 tools across 16, cut input tokens by 58.2% to 92.8%, held pass rates at 100%, and dropped estimated cost by as much as 92.2%. At 508 tools, describing the catalog alone would eat a large share of your context window before the agent does any work.

The evaluation that separates a real gateway from a demo is a call that should be denied. The agent says "delete the inactive customer records," the tool request is DELETE /customers?status=inactive, and the policy allows reads but not deletes. Execution should never happen. Then test the return path: a tool result containing an access token or another customer's record has to be blocked or redacted before the model sees it. Controls before execution, controls after.

Time to working code beats tokens per second ​

Nobody pays a team for keystrokes. What matters is time to working code, generation plus debug plus verify. If a raw agent emits 400 plausible lines in 12 seconds and you spend three hours chasing a lifecycle leak it introduced, that 12-second generation was a cheap way to buy an expensive afternoon.

Boehm's cost-of-defect curve ran at roughly 1:10:100 across design, testing, and production. With current API pricing on one end and senior salaries on the other, it stretches to about $1:$500:$25,000. A fresh-context critic on an uncommitted diff costs $0.25 to $0.75 in tokens and about 45 seconds. Human PR review costs $150 to $400 in loaded engineer time plus a day of calendar latency. An escape to production runs $5,000 to $50,000 before you count trust damage.

Pinching fifty cents of critic tokens to save a subagent call is refusing to buy a two-dollar fuse.

There's a counterintuitive result in the same direction. Forking short-lived subagents with clean 15k to 25k contexts usually burns fewer tokens than one monolithic session, because every turn in a single chat re-sends the whole prefix. A session that bloats to 150k tokens and then runs 40 debug turns billed 6 million input tokens right before slamming into the 200k compaction wall.

The ledger behind that chart matters more than the chart. Across 375 tickets and 689 codified lessons, repeat code regressions sat at 0.0%. Repeat harness failures sat at 9.87%, and they clustered in the final seventy tickets, in workflow reflexes rather than code: modal tool calls fired with null content, subagent polling loops calling manage_subagents(list) instead of waiting on a reactive wakeup, approval banners emitted before the critic returned.

That split tells you prose lessons have a ceiling. Once tool-use training favors polling, another paragraph of Markdown won't stop it. You enforce that boundary in the harness with a schema check, a tool wrapper, or a compiler lock.

Two ways to make output checkable ​

The canary experiment is the cleanest negative result I've read this year. The setup: an instruction in AGENTS.md requiring the first nonempty line of the final response to be CANARY:<token>, 30 attempts across three tasks, 15 with the marker and 15 without, with code graded by checks the agent can't see.

Result: 30 of 30 passed feature and rule checks, 15 of 15 markers matched exactly. Uniform green, which means the study can't show a missing canary predicts anything, because nothing failed. The pilot run is more instructive than the main data. The runtime was missing an execution helper, the feature was never built, and the canary still appeared. A visible signal with no agreed meaning is decoration.

What makes a marker useful is a contract around it. Decide what an omission should trigger, pair the marker with a behavioral check for the thing you care about, and keep instruction loading, marker compliance, and feature completion as separate observations.

The second approach earns its keep on real infrastructure. A Well-Architected review skill reads your infrastructure-as-code and application code, fetches the current framework from live documentation at review time, and scores every best practice with a five-value status.

Run against a public serverless sample, it evaluated 63 of 63 Security best practices and returned 3 out of 5 maturity: 0 critical, 4 high, 5 medium, 7 low. It credited the good parts, including least-privilege Lambda roles, encryption at rest, and a pipeline with a manual approval gate and a pre-traffic smoke test. The top high finding was a CDK deploy role holding IAMFullAccess plus six more full-access policies at pipeline/lib/pipeline-stack.ts:79-86, flagged as a privilege-escalation path and mapped to two best-practice IDs.

The most reassuring number in that report was 27. Twenty-seven best practices came back Cannot Determine rather than guessed, because account-level controls aren't visible in a single workload's code. A tool that says "not observed within declared scope" is one I'll trust on the rest.

Common pitfalls ​

  1. No spend ceiling before the first deploy. Set the limit the moment the account leaves free tier, since the upgrade covers every project at once and doesn't reverse. An agent looping on a failing build burns credit silently.
  2. Approval logic living in the system prompt. It belongs in the tool layer, enforced at runtime, with a schema check that rejects out-of-scope arguments before the call leaves the process.
  3. Sizing one worker per user. Divide peak concurrent actors by 80% of per-worker capacity, keep 20% headroom, and leave the rest as snapshots.
  4. Treating a resume as a reboot with extra steps. Memory and files come back; open MCP sessions and database connections don't. Reconnect them after every wake and supervise anything holding a port.
  5. Assuming the region in your profile is the region your project gets. The provider assigns it. Confirm it in the project overview before you build, because every regional resource depends on it.

What I ran into ​

The region mismatch hit me exactly as described. My profile said us-east-1, the project landed in us-east-2, and the agent caught it, pointed me at the console location, and fixed the profile once I confirmed. Ten seconds of work that would have cost a lot more across twenty resources.

The money check is what made me relax. Watching a sandboxed call fetch plan state and credit balance, then hearing the agent say the deployment wouldn't touch it, feels different from reading a changelog. It skipped WAF and explained the monthly cost, which is a decision a beginner can't make because they don't know the option exists.

On the registry side, my drift was slow and boring. A token that started read-scoped picked up write on another repo during a debugging session, and nothing in the diff flagged it. What worked was snapshotting effective permissions at the provider on a schedule and on every registry change, then comparing both. The alert has an owner or it's a dashboard nobody opens.

The token bill, when I finally looked, came from a monolithic session that had bloated past 120k tokens. Splitting the critic into a fresh 20k-context subagent cut daily spend and caught bugs the long session had talked itself out of.

One thing to remember ​

An agent is a natural-language client for whatever API you hand it. The authority lives in the tool definition. Every control that matters sits outside the model: a spend limit, a credential that expires, a sandbox per session, a declared action class, an independent check on the output. Build those and a model's mistakes cost you a prompt. Skip them and they cost you $6,531.30.

The bottom line ​

If you're putting an agent in front of a cloud account this quarter, start it through a flow that issues short-lived credentials and set a spend limit before the first deploy. The DN42 bill happened because provisioning had no ceiling, not because the model was weak.

If you're running agents past a few hundred sessions, stop sizing for signups and size for peak concurrent turns. Suspend idle actors, reconnect MCP and database sessions on wake, and benchmark what survives a resume before you trust a sub-second number.

If you're reviewing agent changes, add the tool registry to CODEOWNERS and fail CI when an action class, identity, or approval flag changes without a named approval. Watch the permissions that creep up across three PRs. One expansion at a time always looks reasonable.