Building Pluggable AI Agents: A Practical Guide to Models and Harness

    This guide explains how to structure AI agents as a pluggable system that separates the model from the Harness runtime. It covers registering multimodal model capabilities, adding web search and vertical datasets, implementing layered memory, building an evaluation loop, and managing governance and budgets. Engineers will find a practical rollout sequence for moving from a minimal working agent to a continuously optimized, well-governed system.

    1. Why Separate the Model from the Harness

    In engineering practice, an agent that reliably delivers value can usually be abstracted into two orthogonal parts: the model responsible for reasoning and generation, and the runtime framework wrapped around the model that handles perception, action, memory, and constraints—commonly called the Harness. The model sets the upper bound; the Harness sets the lower bound. The core benefit of decoupling them is that the model can be swapped as business and cost goals change, while tools, data, memory, and governance policies accumulate as team assets that can be reused across projects.

    If these capabilities are hard-coded together, the usual consequences are: swapping the model requires rewriting the tool-calling logic; moving to a new business scenario requires rebuilding retrieval and memory from scratch; and permissions, quotas, and audits end up scattered everywhere, making unified governance difficult. This article therefore advocates organizing agents as “slots + plugins”: the runtime defines standard slots, and capabilities are injected as plugins.

    1. Agent = Model(reasoning and generation)
    2. + Harness(slots: tools / data / memory / governance / orchestration)

    2. The Brain Layer: Integrating Multimodal Model Capabilities

    The model layer needs to cover at least four foundational capabilities: text understanding and generation, image generation, video generation, and vectorization for semantic retrieval. In engineering terms, it is recommended to register them uniformly in the runtime’s “model settings” as a “custom provider,” authenticated via API keys. This way, the model catalog, quotas, and billing can be managed in one place, avoiding a separate set of credentials for every project.

    The key after integration is not that “it connects,” but that “it is governable.” It is advisable to set a default model and a fallback model for each capability, and to define timeout, retry, and failure-fallback policies. A sample configuration structure is shown below (the fields are generic illustrations, not a specific API):

    1. {
    2. "provider": "custom",
    3. "auth": { "type": "api_key", "env": "MODEL_API_KEY" },
    4. "models": {
    5. "chat": { "primary": "text-model-a", "fallback": "text-model-b" },
    6. "image": { "primary": "image-model-a" },
    7. "video": { "primary": "video-model-a" },
    8. "embed": { "primary": "embedding-model-a", "dim": 1024 }
    9. },
    10. "policy": { "timeout_ms": 20000, "retry": 2 }
    11. }

    It is worth emphasizing that once the embedding model is changed, historical vectors must be rebuilt in full. The dimension and model version should therefore be brought under change management to prevent retrieval quality from degrading unnoticed.

    3. The Hands Layer: Layered Integration of Tools and Data

    3.1 Web Search: Solving “Knowledge Has a Cutoff Date, Tasks Do Not”

    The model’s knowledge is static, while business questions are often dynamic. A web search plugin should provide at least four capabilities: real-time fact retrieval, verifiable sources, authoritative-source filtering, and time-range filtering, plus automatic query rewriting (expanding a colloquial question into multiple high-quality search queries). In engineering terms, it is recommended to split retrieval into four steps—rewrite, recall, rerank, and cite—and to enforce citations in the answer to support human review.

    1. def web_answer(query, top_k=5, freshness="30d", domains=None):
    2. queries = rewrite(query) # Query rewriting to generate multiple search queries
    3. docs = search(queries, top_k=top_k, # Multi-path recall
    4. freshness=freshness, # Time-range constraint
    5. allow_domains=domains) # Authoritative-source filtering
    6. ranked = rerank(query, docs)[:top_k] # Relevance reranking
    7. return synthesize(query, ranked, cite=True)

    3.2 Vertical Datasets: Solving “What General Search Cannot Provide—Structured Facts”

    For content such as public company financial reports, business registration information, judicial risk, academic papers, vehicle configurations, and macroeconomic indicators, general search often only returns scattered web pages, whereas the business needs structured, traceable fields. A viable approach is to introduce vertical dataset plugins that automatically route to the corresponding database based on query intent: when asking about financial metrics, route to the financial database and return time series; when asking about a specific model’s configuration, route to the product specification database and return key-value structures. The routing layer should explicitly declare an “intent-to-data-source” mapping and retain an override entry for manually specifying the data source, to prevent misrouting.

    1. Intent recognition → data source routing → parameterized query → structured result → citation and methodology notes

    Methodology notes are especially important: the same metric may have different statistical periods and consolidation scopes across data sources, so the output should include the methodology and a timestamp.

    3.3 Memory: Solving “It Doesn’t Remember You Across Sessions”

    The memory mechanism can draw on the idea of a “virtual file system + semantic retrieval”: abstract memory, resources, and skills uniformly as files, load them in layers, recall them on demand, and automatically consolidate long-term memory after a session ends. The layers typically include: short-term context within a session, project-level long-term memory, and team-level shared knowledge. On the write side, deduplication and conflict resolution are needed; on the read side, intent should be determined first to decide which layer to recall from, avoiding stuffing irrelevant memory into the context and driving up costs.

    1. def recall(session, user_msg, budget=4000):
    2. intent = classify(user_msg) # Determine whether long-term memory is needed
    3. layers = ["session"] if intent == "chitchat" else ["session", "project", "team"]
    4. hits = memory.search(user_msg, layers=layers, limit=8)
    5. return memory.render(hits, token_budget=budget) # Render within budget; truncate if exceeded

    4. The Growth Layer: From “It Runs” to “It Gets Better the More It Runs”

    Self-evolution should not be a vague slogan, but a measurable closed loop: collect failure samples → attribute causes (missing tools / inaccurate retrieval / poor prompts / memory contamination) → apply targeted fixes (add plugins, adjust routing, revise prompts, clear memory) → run regression evaluation → canary release. It is advisable to maintain a small evaluation set that covers typical failure modes, and run it for any prompt or tool change, using two metrics—pass rate and average number of steps—to constrain quality and avoid “fixing one thing and breaking three.”

    5. Governance and Budget: The Engineering Value of One Subscription with Unified Deduction

    When the model and various capability components come from the same subscription system with a unified quota deduction, the most direct benefit is budget predictability: no need to open and account for each capability separately, with costs consolidated into a single bill, making it easy to allocate by project and set alert thresholds. On the governance side, it is recommended to complete three things: centralized key hosting and rotation, per-caller quotas and rate limiting, and full-chain logging and auditing (recording the model, tools, data sources, and elapsed time). This is both a basis for troubleshooting and a foundation for compliance.

    1. First connect the model layer and unified authentication to run a minimal closed loop;
    2. Add web search and enforce citations;
    3. Introduce one or two vertical data sources based on business needs, with clear methodology;
    4. Add layered memory, setting recall budgets and write deduplication;
    5. Build an evaluation set and canary mechanism to enter continuous optimization;
    6. Finally complete quotas, auditing, and alerting to reach an operable state.

    Following this sequence, the team can obtain usable output at every stage, rather than waiting until “all components are ready” for the first launch. The value of components lies not in their number, but in whether they are constrained by the same slot specification and can be governed and measured uniformly—this is the true engineering meaning of “abundance with substance.”