Handbook

Production agent systems need bounds, not bigger prompts

A practical operating model for goals, context, tools, budgets, stopping conditions, and graceful failure in agentic systems.

Shad KhanJuly 202612 min read

Production agent systems need bounds, not bigger prompts

A practical operating model for goals, context, tools, budgets, stopping conditions, and graceful failure in agentic systems.

An agent is a control loop. Production reliability begins when every part of that loop has an explicit boundary.

The demo hides the loop

A successful agent demo usually shows the happy path: a goal arrives, the model plans, tools are called, and a polished answer appears. Production exposes the missing questions. How much context can the agent collect? Which actions are reversible? Who is allowed to approve a write? When should the loop stop? What happens when the model is uncertain but confident-sounding?

These are not prompt-writing details. They are system boundaries. If they remain implicit, the model becomes the place where policy, orchestration, error handling, and product behavior are accidentally mixed together.

System design: the agent control loop

I use five dimensions to review an agent before discussing model quality. The goal must be narrow enough to declare success. Context must have source, relevance, freshness, and size limits. Tools must have contracts and authorization. Budget must cover time, tokens, calls, and money. Stopping conditions must define completion, escalation, and safe failure.

Architecture diagram

Goal

  • One task with an observable, checkable completion condition
  • No implicit second task hiding inside a broad instruction

Context

  • Approved sources only — no open-ended crawling of whatever the model can reach
  • Retrieval limits by size, recency, and relevance
  • Freshness rules tied to the source system, not the retrieval cache

Tools

  • Typed inputs validated before execution, not after a failure
  • Explicit permission scope per tool, per caller — never a shared service identity
  • Idempotency keys so a retried call cannot double-execute
  • Normalized error shapes the model can reason about instead of raw stack traces

Budget

  • Maximum steps, wall-clock time, tokens, and dollar cost, set before the task starts
  • Bounded retries with backoff, never an unbounded loop
  • Budget consumption visible mid-task, not only after the task has already failed

Stop condition

  • Success defined by the task contract, not by fluent-sounding text
  • No-progress detection after repeated identical attempts
  • A defined escalation path to a human when confidence is low
  • A graceful fallback that explains what was and was not done

Separate reasoning from execution

Models are useful for interpreting ambiguity, forming a plan, choosing among permitted options, and explaining results. Deterministic code should validate schemas, enforce policy, calculate permissions, execute transactions, and record evidence. This split is one of the strongest reliability controls available.

Architecture diagram

The model may propose 'update the lead stage.' The platform decides whether that tool is visible, whether the user has scope, whether the transition is valid, whether approval is required, and whether the request has already been applied. The action remains useful without asking probabilistic text generation to become a transaction engine.

Observe the task, not only the model call

A trace that records only prompt, response, and latency is too shallow. Production incidents often live between calls: repeated planning, retrieval growth, tool retries, partial writes, model routing, cache misses, or policy denials. Task-level tracing must connect those events into one narrative.

The useful operational unit is the user task. A team should be able to see the path taken, the evidence used, the actions attempted, the budget consumed, the reason the loop stopped, and the outcome shown to the user.

From production: the reflection loop that caught its own mistake

On the Bedrock knowledge-base platform, the supervisor agent runs a bounded reflection pass before returning any answer — not open-ended self-critique, but a fixed checklist: did every claim have retrieved evidence or tool output, did the response stay inside tenant and role permissions, did any worker disagree with another worker, did the SQL query run against the current schema, did model routing stay inside its cost and latency budget. When a check failed, the auto-heal actions were deliberately narrow: retry retrieval with adjusted filters, refresh the schema before regenerating a query, fall back from semantic cache to live retrieval, re-route to a different model, ask a worker for a narrower answer, or escalate to a human. The loop had a hard cap on repair attempts. Past that cap, the assistant returned a transparent partial answer instead of a fabricated complete one — because the stop condition for "give an honest partial result" has to be designed before the demo ever asks for it.

The same platform's SQL agent shows what a bounded stop condition looks like under a real failure, not a hypothetical one: a renamed column or dropped join key doesn't cause endless retries of the same broken query. It observes the database error, refreshes the schema, re-maps the original question against the fields that still exist, rewrites the query inside the same read-only contract, validates row count and units, and escalates rather than fabricates if the schema no longer supports the question at all. Every one of those queries still carried a tenant identifier, a role scope, and a cost budget — the authorization boundary from the "separate reasoning from execution" section, applied to a live production database instead of a CRM field.

AgentBid takes the same principle to its logical extreme: the bidding decision itself has no model in the loop at all. The auction path is a small, deterministic, benchmarkable service with a strict latency budget, and agents only operate one layer up, on an asynchronous plane, through read-first tools with explicit budgets and reversible actions. Keeping the model out of the hot path entirely is what makes the sub-five-millisecond execution target possible — the goal was never to make the agent faster, it was to decide the agent didn't belong on that path at all.

What to carry forward

  • Treat agents as bounded control loops
  • Keep authorization and execution deterministic
  • Measure task outcomes beside model metrics
  • Design escalation and degradation before autonomy
  • Cap repair attempts and design the honest partial answer before the demo asks for one

Applied in the portfolio

  • Enterprise MCP Gateway — A governed integration layer that turns enterprise APIs into safe, versioned tools for production AI agents.
  • AgentBid — An open architecture for real-time bidding operations, combining a high-throughput data plane with explainable AI assistance.
  • Enterprise Knowledge Base Multi-Agents on AWS Bedrock — A governed AWS Bedrock knowledge platform for multi-source ingestion, multi-agent reasoning, semantic retrieval, observability, and FinOps.