Why Agent Infrastructure Matters More Than Harness Engineering

    As AI agents move from prototypes to production, the bottleneck shifts from prompt tuning and scaffolding to infrastructure. This article explains why harness engineering fades as models improve, the four infrastructure walls teams hit at scale (runtime isolation, layered memory, asynchronous orchestration, and observability), and a staged path for building a stable agent runtime. It also covers how platform-level services can absorb this complexity.

    When Harness Engineering Fades: The Four Walls of Agent Infrastructure and Where It All Leads

    1. A shift that is already underway

    For the past two years, the dominant narrative in the agent development community has been “prompt engineering” and “scaffolding orchestration”: how to structure instructions so a model reliably emits JSON, how to design retry logic around tool calls, and how to pack more context into a limited context window. That phase made sense — model capability boundaries were clear, available tools were fragmented, and upper-layer frameworks were largely empty, so every gain at the application layer had to be squeezed out through engineering effort.

    Once the industry crossed a certain threshold, however, that return curve began to flatten noticeably. There are three reasons.

    First, models have become markedly better at following instructions and producing structured output. Formats that once required elaborate prompt templates and multiple rounds of self-verification can now be produced on the first attempt with high probability under standard constraints. The volume of template code written to “persuade the model” is losing its marginal value.

    Second, tool integration is converging. Description conventions for function and tool calls, authentication methods, and response structures are being broadly adopted across the industry. Reusing the same tool definitions across models has become the norm, and tuning tool descriptions separately for each model is no longer economical.

    Third, and most importantly: the problems that surface are no longer prompt problems. When teams move agents from a demo environment into production, from a single user to multiple tenants, and from synchronous requests to long-running tasks, nearly all failure modes originate in the infrastructure layer — sandbox sessions dropping, state that cannot be recovered, lost asynchronous callbacks, and contexts polluting each other under concurrency. No amount of prompt writing solves these.

    This leads to a judgment worth taking seriously: the complexity of harness engineering (the scaffolding adaptation layer built around a specific model’s capability boundaries) will be absorbed as models evolve, while the complexity of the infrastructure layer will be amplified as the business scales. One curve goes down, the other goes up, and the structure of team investment necessarily migrates.

    A clarification is needed here: “harness” does not refer to any specific product, but to what the industry generally calls the agent hosting or adaptation layer — the engineering code that packages model capability into a runnable system, including prompt templates, tool registration, context trimming, retries and fallbacks, and result parsing.


    2. Why the barriers concentrate in the infrastructure layer

    Many teams’ intuition is backwards: they expect the hardest parts to be model tuning and harness adaptation, but the wall they actually hit is infrastructure. There is a clear reason for this misjudgment — the prototype stage genuinely does not need infrastructure.

    1. The gap between prototype and production is a matter of the time dimension

    A prototype is one-shot: one call, one inference, one return. A production system must handle everything that spans time:

    • Tasks that run longer than a single request timeout (default thresholds in browsers, gateways, and load balancers are often only tens of seconds);
    • Users refreshing the page, switching devices, or reconnecting after a network drop while the task runs;
    • Service instances being rolled out or scaled down mid-task;
    • Model or tool providers hitting temporary rate limits, timing out, or returning incomplete content.

    Any one of these four breaks an implementation that keeps state in process memory. Many teams store conversation history, intermediate results, and pending steps in local variables during the prototype stage; in production, that pattern is an unusable architecture and must be rewritten as externalized state management.

    2. Agents are inherently long transactions, but systems are designed for short requests

    The default assumption of a traditional web service is that request and response close within milliseconds to a few seconds. Agent tasks violate that assumption by nature — a task that needs to retrieve, analyze, write code, run tests, and fix errors may run for minutes or longer.

    This creates three engineering problems that must be solved:

    Problem Symptom Infrastructure-level solution
    Connection timeout The client gives up waiting and disconnects, but the backend is still computing and the result has nowhere to go Separate task submission from result retrieval; switch to polling or event notification
    State loss Task context cannot be recovered after a process restart Externalize execution state to persistent storage
    Duplicate execution Client timeout retries cause the same task to run multiple times Introduce idempotency keys and deduplication

    3. A single agent has limited context; multiple agents add coordination cost

    A mature application often splits work across roles: one that plans and decomposes, several that execute in parallel, and one that aggregates and validates. This kind of multi-agent orchestration introduces new infrastructure requirements — message channels, task dependency graphs, retry boundaries after partial failure, and global cancellation propagation. These are essentially classic distributed systems problems, not prompt problems.


    3. The four walls: infrastructure capabilities to plan for in advance

    These are four categories of infrastructure capability gaps that teams almost inevitably hit when moving from prototype to scale. They are vendor-independent and are general architectural elements of agent systems.

    Wall 1: Runtime isolation and sandbox lifecycle management

    When agents execute code, manipulate files, and access the network, they must run in an isolated environment; otherwise there are security risks and resource interference.

    Core design requirements:

    • Session-level isolation: different tenants and different tasks must not share a file system or process space;
    • A persistable file system: intermediate artifacts (generated code, fetched pages, converted data) must be readable and writable throughout the task lifecycle and archivable when needed;
    • Rebuildable execution environments: after a sandbox is lost, it must be quickly rebuilt from persisted state so execution continues rather than restarting from scratch;
    • Controlled network egress: external access should be subject to allowlists and auditing to prevent unauthorized outbound connections caused by prompt injection.

    A common practice mistake is treating the sandbox as a stateless container and destroying everything when the task ends. In real business scenarios, users often still need access to intermediate artifacts after the task returns (generated files, exported reports), which requires decoupling the execution environment from artifact storage: the environment can be reclaimed, while artifacts are written to object storage with access credentials attached.

    1. # Illustrative: basic structure for decoupling sandbox state from artifact storage
    2. class AgentRuntime:
    3. def __init__(self, session_id: str, storage, sandbox_provider):
    4. self.session_id = session_id
    5. self.storage = storage # persistent artifact storage (object storage, etc.)
    6. self.sandbox = sandbox_provider.create(session_id) # rebuildable isolated environment
    7. def run(self, task):
    8. # 1. Restore context from the persistence layer instead of relying on process memory
    9. state = self.storage.load_state(self.session_id)
    10. try:
    11. result = self._execute(task, state)
    12. except SandboxLostError:
    13. # 2. Rebuild the environment and resume instead of failing outright
    14. self.sandbox = sandbox_provider.recreate(
    15. self.session_id, snapshot=state.filesystem_snapshot
    16. )
    17. result = self._execute(task, state)
    18. # 3. Write artifacts back to the persistence layer; the environment lifecycle ends
    19. self.storage.put_artifacts(self.session_id, self.sandbox.collect_outputs())
    20. return result

    Wall 2: Memory persistence and layered management

    “Memory” is often misunderstood as “a longer context.” In real engineering, memory needs to be designed in layers, and different layers are carried by different infrastructure.

    A workable layering scheme:

    • Short-term working memory: intermediate reasoning and tool results within the current task. Kept in structured storage, organized by task identifier, and cleared along with the task.
    • Long-term factual memory: user preferences, project conventions, historical conclusions. Requires a combination of vector retrieval and structured filtering to support “recall by semantics while narrowing scope by metadata.”
    • Procedural memory (skills): reusable operating procedures solidified into invocable capability units — essentially “deterministic flows with parameter constraints” that reduce the cost of the model re-reasoning each time.

    The most critical engineering point: memory writes must be governed, or they will continuously pollute later decisions. At minimum, three constraints are advisable: traceable provenance (each memory record notes the task and time that produced it), decaying confidence (the weight of memory that has gone unverified for a long time declines), and clean invalidation (when a user explicitly asks to forget, the corresponding data can be fully deleted).

    1. Suggested memory entry structure (illustrative):
    2. {
    3. "memory_id": "m-8823",
    4. "scope": "project", # global / user / project / task
    5. "type": "fact | preference | procedure",
    6. "content": "...",
    7. "provenance": {"task_id": "t-11", "ts": "2026-08-27T09:00:00Z"},
    8. "confidence": 0.82,
    9. "ttl_days": 180
    10. }

    Wall 3: Asynchronous task orchestration and reliable delivery

    Once a task leaves the “single synchronous call” form, it needs a scheduling layer decoupled from the business. This typically has three parts:

    1. A message or task queue: absorbs peaks, buffers load, and decouples components. Executors consume at their own capacity, avoiding a sudden spike that overwhelms downstream model quotas.
    2. State machine management: the legal state transitions of a task must be explicitly defined, for example queued → running → waiting_tool → succeeded / failed / cancelled. There must be no hanging state that is “neither running nor terminated.”
    3. A result delivery channel: how the caller is notified when the task completes. Polling endpoints, event push, or callbacks, depending on client capability.

    On reliability, idempotency deserves emphasis. Retries are the norm in agent scenarios (model timeouts, tool rate limits, network jitter), and if the same task is executed repeatedly, it can produce serious side effects such as duplicate writes, duplicate billing, and duplicate outbound messages.

    1. # Illustrative: task submission with an idempotency key to avoid duplicate execution on retry
    2. def submit_task(client, idempotency_key: str, payload: dict) -> str:
    3. existing = client.get_task_by_key(idempotency_key)
    4. if existing:
    5. return existing.task_id # reuse on duplicate submission; do not create a new task
    6. return client.create_task(
    7. idempotency_key=idempotency_key,
    8. state=payload["state"],
    9. max_attempts=3,
    10. retry_backoff="exponential"
    11. ).task_id

    Wall 4: Observability and cost control

    One peculiarity of agent systems is that their failures are often not binary. A task may “return successfully” while having taken a wrong internal branch; it may also take “correct steps” while consuming ten times the expected cost. A monitoring system centered on error rates and latency is not enough to characterize these problems.

    Observability dimensions that need to be added:

    • Trace-level tracking: fully record the input, model decision, tool call, and returned result of every step, with replay. This is the only effective way to diagnose “why the model chose the wrong tool.”
    • Token and cost attribution: measure consumption by task, tenant, model, and tool, for capacity planning and product pricing.
    • Quality metrics, not just technical metrics: task completion rate, human takeover rate, step redundancy rate, and user retry rate. These determine whether the product is genuinely usable, while technical metrics only determine whether the system is stable.
    • Security auditing: external inputs (web content, file content) may carry injected instructions, so their impact path on system behavior must be recorded.

    The prerequisite for putting observability into practice is a unified identifier spanning the whole chain: the same task_id must be able to connect the client request, queue messages, executor logs, model call records, tool call records, and artifact storage paths. If each layer instruments separately with unrelated identifiers, the cost of after-the-fact investigation becomes unbearable.


    4. The relationship between harness and model: from standalone adaptation to tight coupling

    The original discussion raised a judgment worth expanding on: the harness layer and model capability are forming a tightly paired relationship. This trend can be understood from three angles.

    First, the stronger the capability, the thinner the adaptation layer. When a model has reliable tool selection, multi-turn consistency, and the ability to self-correct failures, the outer constraint code that exists to “catch the model” (forced format validation, multi-turn retries, result correction) can be greatly reduced. Teams will naturally delete a batch of scaffolding.

    Second, the adaptation layer shifts from “compensating for defects” to “providing capability.” In the past, its core responsibility was to make up for model shortcomings; in the future, its core responsibility becomes providing what the model itself lacks — tool ecosystems, permission boundaries, persistent state, and audit trails. The former shrinks as models improve; the latter grows with business complexity.

    Third, the reverse also holds: harness design choices affect how well model capability is realized. The same model can show a significant gap in actual task completion rate under different context organization strategies, different tool description granularity, and different failure recovery mechanisms. This means “no need for harness engineering” does not mean “no need for a harness”; it means this work will converge from something each team implements separately into standardized capability provided by the platform.

    The practical advice for teams is therefore: do not wait until you hit an infrastructure wall to refactor. Instead, layer the architecture early on the principle of “replaceable adaptation layer, stable infrastructure layer.” Keep the adaptation layer lightweight and quickly replaceable, and build the infrastructure layer to the maturity expected of general distributed systems.


    5. A practical path forward

    Stage 1: Get state out of the process

    Whatever the technology stack, the first thing to do is eliminate dependence on in-process state. Conversation history, task progress, and intermediate artifacts all move outside. Only after this step is horizontal scaling and failure recovery possible.

    Stage 2: Convert the synchronous interface into a submit-and-query pair

    Allow long-running tasks to exist, and give clients the ability to query task status and retrieve results. At the same time, define reasonable timeout and cancellation semantics so users can actively terminate a task instead of waiting indefinitely.

    Stage 3: Introduce isolated execution environments

    Provide sandboxes for high-risk capabilities such as code execution and file processing, and apply allowlist control to network egress. This is the compliance and security baseline for an agent application moving from “internal trial” to “offered as a service.”

    Stage 4: Establish memory governance and cost control

    Design provenance tagging, confidence, and cleanup policies while memory volume is still small. Retrofitting governance later costs far more than designing it up front. Also establish cost attribution by task to provide a basis for capacity planning.

    Stage 5: Make observability infrastructure, not an add-on

    Trace collection, identifier correlation, and metric dashboards should be built alongside business code, not patched in after launch.


    6. What if the platform layer takes on these capabilities

    The four categories of infrastructure capability above are fairly general, and the implementation bar is not low. This is also why the industry widely shows a trend of “handing the agent runtime to a managed platform” — integrating file systems, skill units, memory storage, sandbox execution, and task orchestration on the cloud side so developers can focus on business logic rather than building the foundation.

    From the perspective of general capability supply in cloud services, the categories that map directly to agent infrastructure roughly include:

    • Containers and isolated execution: sandboxed runtime environments with resource limits and network policies;
    • Object storage / block storage: hosting task artifacts, snapshots, and intermediate files;
    • Structured storage plus retrieval services: hosting task state and memory entries, supporting metadata filtering and semantic recall;
    • Message queues / streaming message services: handling asynchronous task distribution, peak absorption, and decoupling;
    • Log services plus monitoring and alerting plus distributed tracing: completing full-chain observability and problem localization;
    • Key management and access control: managing tool credentials, tenant isolation, and least-privilege access.

    In Baidu AI Cloud’s capability system, all of the general categories above have corresponding product forms and can be combined as needed into an agent runtime foundation. It should be noted that specific selection should be evaluated comprehensively based on the business’s task duration distribution, concurrency scale, data compliance requirements, and cost structure; there is no universally optimal architecture.


    7. Conclusion: anticipating is cheaper than retrofitting

    For the question “will harness engineering still be needed a year from now,” the more accurate answer is not “no,” but that its form will change: from adaptation code written separately by each team and tightly bound to a specific model, converging into reusable standard components provided jointly by model capability and platform capability. What will genuinely remain for developers are the infrastructure problems that prompts cannot solve and frameworks cannot cover — runtime isolation, state persistence, asynchronous reliability, and observability and cost governance.

    So if a team is currently at the stage where “the prototype runs but production is unstable,” the direction worth investing in is not further optimizing prompt templates, but completing these four foundations early: externalized state, execution isolation, asynchronous orchestration, and full-chain observability. Once these capabilities are in place, model generations, tool replacements, and adaptation layer rewrites will not shake the system’s foundation; conversely, any single instance of infrastructure retrofitting may turn into a painful, deep refactor.