Agent Engineering in Practice: A Guide to Building Production-Ready AI Agents

    This guide explains why reliable AI agents depend on the engineering harness around the model, not the model alone. It breaks a production agent system into four layers—model, access, harness, and scenario—and walks through adding all-modality model access, then five harness components: search, data, memory, evolution, and output. It also covers assembly order, minimal validation loops, budget governance, and common anti-patterns to avoid.

    1. Background: The Bottleneck Has Shifted from the Model to the Engineering Harness

    Over the past two years, the industry’s view of AI agents has shifted noticeably. Early on, teams competed on whose model was stronger. Once agents were placed into real business workflows, however, the problems surfaced outside the model itself: Can the agent reliably obtain trustworthy information? Can it retain context across sessions? Can it self-correct after a failure? Can it turn results into deliverable artifacts?

    The industry has gradually converged on a shared abstraction:

    1. Agent = Model + Harness

    The Model sets the ceiling on intelligence; the Harness determines whether the agent can do the work reliably. The Harness is the full set of engineering capabilities wrapped around the model: prompt and context organization, tool calling and slot extensions, retrieval and data access, memory read/write, evaluation and self-optimization, and artifact rendering and export. With the same model, different harnesses can differ severalfold in real-world usability.

    This leads to three practical pain points:

    • High selection cost: The number of pluggable components has exploded, forcing developers to trial-and-error through countless plugins before knowing which search to use and which data source to trust.
    • Missing memory and evolution: Most prototypes offer only “single-turn Q&A plus tool calling,” with no long-term memory or iteration mechanism, so experience cannot accumulate.
    • Out-of-control budgets: Models, retrieval, and storage are billed separately, quotas are scattered, and there is no unified budget view.

    Using Baidu AI Cloud’s Qianfan Agent Plan and the harness slot mechanism of an AI coding tool as examples, this article presents a transferable set of engineering practices.

    2. Overall Architecture: Split Capabilities into “Brain + Hands and Feet + Memory”

    It is recommended to divide the agent system into four layers with clear boundaries that can be replaced independently:

    Layer Responsibility Key Design Point
    Model layer Text, image, and video generation, plus vectorization Unified protocol access for easy replacement
    Access layer Authentication, quota, budget One set of credentials for unified deduction and centralized control
    Harness layer Search, data, memory, evolution, artifacts Slot-based assembly, enabled on demand
    Scenario layer Business workflows and deliverables Clear acceptance criteria and human fallback

    The core principle is “subscribe once, share one quota”: bundle the model with commonly used harness components and settle them against the same quota. This reduces bill fragmentation and makes budgets predictable and allocable within a team.

    3. Step 1: Give the Agent a “Brain”—All-Modality Model Access

    The model layer should cover four foundational capabilities: text generation, image generation, video generation, and vectorization. The first three handle generation and expression; vectorization turns unstructured content into a retrievable representation and is a prerequisite for memory and retrieval.

    In AI coding tools that support custom providers, the access path is typically Settings → Models → Add Custom Provider, where you enter a compatible endpoint URL and a dedicated API key. Example configuration:

    1. {
    2. "provider": "custom",
    3. "base_url": "https://<your-endpoint>/v1",
    4. "api_key": "<your-key>",
    5. "models": {
    6. "chat": "text-model",
    7. "embedding": "embedding-model",
    8. "image": "image-model"
    9. }
    10. }

    Engineering recommendations:

    • Abstract a model gateway layer so business code depends only on a unified interface and switching providers requires no business changes.
    • Assign different model tiers to different tasks: small models for extraction and classification, stronger models for planning and writing.
    • Set timeouts, retries, and fallback strategies for generation calls to prevent a single point of failure from blocking the main workflow.

    4. Step 2: Add “Hands, Feet, and Memory”—Five Harness Components

    1. Search component: solving “information freshness”

    Responsible for web retrieval, result ranking, and source attribution. When selecting one, look at three things: whether it returns structured snippets, whether domain whitelists can be configured, and whether it provides citable sources. In practice, making “citation source” a mandatory field in the prompt significantly reduces hallucination.

    2. Data component: solving “which source to trust”

    In enterprise settings, the same question often has multiple data sources. Establish a credibility hierarchy: authoritative business databases > internal knowledge bases > public web pages. Retrieve by tier and explicitly label the source level in the prompt so the model learns to “prefer higher levels when sources conflict.”

    3. Memory component: solving “remembering things”

    Memory should be designed in layers:

    1. Short-term memory: the current session's context window
    2. Working memory: task state, completed steps, pending items
    3. Long-term memory: preferences, conclusions, and past artifacts in the vector store

    Before writing to long-term memory, deduplicate and summarize; when reading, rank by similarity with time decay to prevent irrelevant history from crowding the context.

    4. Evolution component: solving “growing over time”

    Retain each task’s inputs, tool traces, and human corrections as an evaluation set, and run regression evaluations periodically. Summarize failure cases into rules or few-shot examples and write them back into prompts and the knowledge base, forming a closed loop.

    5. Artifact component: solving “producing deliverables”

    Render results into documents, spreadsheets, charts, or downloadable files, with support for templating and version management, so agent output can enter the delivery workflow directly.

    5. Assembly Order and Validation

    Recommended order: model access → search → data tiering → memory → evolution → artifacts. After adding each layer, run a minimal acceptance check:

    1. Connectivity: one successful call and one expected-failure error-handling case.
    2. Correctness: a fixed set of 20 gold-standard questions, recording accuracy and citation coverage.
    3. Stability: timeout and retry rates under concurrency and long-running tasks.
    4. Cost: average quota consumed per task, with alert thresholds set.

    A minimal evaluation loop:

    1. for case in golden_set:
    2. out = agent.run(case.input)
    3. assert out.citations, "Missing source citations"
    4. score = rubric(case.expected, out)
    5. metrics.append(score)
    6. report(metrics) # accuracy / citation coverage / average latency / average quota

    6. Budget and Governance

    A unified quota brings a direct benefit: simpler governance. Allocate quotas by project, set daily/monthly caps, and rate-limit high-consumption tasks. Putting quota metrics and business metrics on the same dashboard is what lets you judge whether an improvement in quality is worth the cost.

    7. Common Anti-Patterns

    • Component pile-up: installing many plugins without clear responsibility boundaries, causing contexts to contaminate one another.
    • Launching without evaluation: tuning prompts by feel, with no way to tell whether a change is an improvement or a regression.
    • Ungoverned memory: writing without clearing, so long-term memory bloats and retrieval quality keeps declining.
    • Single-point dependency: tightly coupling the model and tools, making replacement costly.

    8. Conclusion

    Whether an agent can enter production depends on the completeness of the harness, not the score of a single model. Using “Model + Harness” as the backbone—first unifying model access and budget management, then assembling search, data, memory, evolution, and artifacts layer by layer, and continuously running a fixed evaluation set for regression—turns the capabilities of a single subscription into a stable, deliverable product.