AI Agents and LLMs in Production: A Technical Guide to Co-Designing Models and Agent Systems
This article examines why large language models and AI agents must be designed and released together, rather than as separate product lines. It explains how model capabilities determine the boundaries of an agent while orchestration determines its experience ceiling, then breaks down a five-layer reference architecture covering access, orchestration, capability, data, and governance layers. Readers will find practical guidance on turning vague office requirements into executable workflows, managing context budgets and tool contracts, enforcing idempotency and compensation for write operations, and building evaluation and cost governance systems. Common pitfalls such as over-automation, neglecting permission inheritance, and delayed evaluation are also discussed.
1. From Model Release to Agent Launch: An Engineering Signal Worth Noting
A clear pattern has recently emerged in the industry: a cloud vendor launched an office-oriented agent product at the same time as a major model version update. Releasing the model and the agent business on the same timeline shows that the two are no longer independent product lines, but are delivered as a single, integrated capability.
For developers and enterprise technical leaders, the value of this signal is not “who shipped what first,” but the clear engineering evolution it reveals: the value of model capabilities is increasingly realized through the agent layer that packages them. A raw model provides probabilistic text generation, while an agent combines the model, tools, data, and process orchestration into a product form that business users can consume directly.
Setting aside specific product attributes, this article focuses on the general technical questions: Why must models and agents be co-designed? What layers make up a deployable agent system? In high-frequency scenarios such as office work, what are the most common engineering pitfalls?
2. Why Models and Agents Must Evolve Together
1. Model capabilities set the boundaries; orchestration sets the experience ceiling
A model’s context window, instruction-following ability, structured output stability, and level of function-calling support directly determine whether an agent can reliably decompose tasks. Conversely, the failure samples an agent exposes under real traffic are the most valuable input for model iteration. Iterating the two separately inevitably leads to two kinds of waste: “the model is over-capable but the product is hard to use,” or “the product workflow is complex but the model cannot handle it.”
2. Interaction is shifting from “conversation” to “task completion”
Early applications used “a single question and answer” as the unit of interaction. Today the unit is “a closed loop for one task”: reading materials, generating a first draft, invoking validation, writing to the target system, and notifying the relevant people. A task closed loop means the system must have state management, failure retries, and permission boundaries. None of these can be provided by the model itself; they must be carried by the agent layer.
3. Cost structure requires joint optimization
A single inference cost is only part of the bill. In agent mode, one task may involve multiple rounds of inference, retrieval, tool calls, and result validation. If the model and the workflow are not designed holistically, token consumption and the number of calls can multiply. The goal of co-design is to minimize “ineffective inference” while keeping quality acceptable.
3. Reference Architecture: A Five-Layer Breakdown
A general agent system can be abstracted into five layers, with clear contracts decoupling each layer from the next.
Access layer Channel adaptation, identity and permissions, session lifecycleOrchestration Task planning, step scheduling, state machine, retry and rollbackCapability layer Model inference, retrieval augmentation, function/tool calls, structured parsingData layer Vector index, business databases, object storage, cacheGovernance layer Log tracing, evaluation sets, quotas and cost, content safety
The key to the access layer is not the protocol but identity. Once an agent can read and write business data, it must inherit the caller’s permissions rather than use a high-privilege “super account.”
For the orchestration layer, an explicit state machine is recommended over free-form planning with unbounded loops. Keep the number of states within an enumerable range, and define a clear input/output contract for each state.
In the capability layer, retrieval and tool calls are the two areas most prone to getting out of control. Set timeouts, retry limits, and fallback paths.
The data layer must distinguish “retrievable knowledge” from “writable business data.” The former allows approximate matching; the latter requires precise addressing and idempotency control.
The governance layer is the dividing line for whether a system can go to production. A system without trace logging is nearly impossible to maintain when locating failures.
4. Office Scenarios: Turning Vague Requirements into Executable Workflows
Office scenarios have become the launch ground for agents because task boundaries are relatively clear, feedback cycles are short, and there is more room for error tolerance. The following order is recommended for implementation.
- Slice the scenario: Do not build a “general office assistant” first. Start with single-target tasks such as “meeting notes organization,” “contract clause extraction,” or “weekly report summarization.”
- Normalize inputs: Convert a user’s colloquial description into structured task parameters, for example:
{"task": "summarize_meeting","source": "doc://meeting/2026-08-31","output": {"type": "bullet", "max_items": 8},"constraints": {"language": "zh", "keep_owner": true}}
- Minimize tools: In the early stage, connect only two or three read-only tools. After verifying stability, gradually open write operations.
- Human confirmation points: For actions involving external sending, submission, or deletion, a confirmation step must be inserted.
- Observability first: Connect logs, metrics, and tracing before launch, rather than adding them after problems occur.
5. Engineering Essentials for Context and Tool Orchestration
The context budget must be managed explicitly. Divide the context into four blocks: system instructions, long-term memory, retrieved snippets, and current task state. Set an upper limit for each, and evict by priority when the limit is exceeded, rather than simply truncating the tail.
Tool descriptions should be written as interface contracts: name, purpose, parameters, return structure, and failure semantics are all required. Vague descriptions directly cause the model to select the wrong tool.
Idempotency and compensation are the baseline for write operations. Any call that changes external state should carry a unique request identifier and have a compensation action designed:
def safe_execute(task_id, tool, payload):key = f"{task_id}:{tool.name}"if cache.exists(key):return cache.get(key) # Idempotent hit, avoids duplicate writestry:result = tool.invoke(payload)cache.set(key, result, ttl=3600)return resultexcept TimeoutError:return degrade(task_id) # Timeout fallback, hand off to a human
6. Evaluation and Cost Governance: Making Quality Measurable
An agent without an evaluation set cannot iterate. Build three layers of evaluation: single-step tool-call accuracy, task-level completion rate, and human preference scores. Keep a failure sample library at each layer as the basis for regression testing and model selection.
For cost governance, start from three areas: first, push deterministic logic down into code rather than the model; second, assign lighter inference tiers to small tasks; third, deduplicate and cache retrieval results to reduce repeated context injection.
On the infrastructure side, the common practice is to connect logs and metrics to a logging service and a monitoring and alerting system, and build dashboards for the latency, failure rate, and token consumption of the model call chain. For this type of requirement, Baidu AI Cloud also provides general-purpose capabilities, such as a container platform to host orchestration services, object storage to hold original documents, and message queues to smooth traffic peaks. Enterprises can combine them freely according to their own architecture.
7. Common Pitfalls and How to Avoid Them
- Pitfall 1: Pursuing full automation. In the early stage, keep human confirmation points and trade controllable failures for accumulated trust.
- Pitfall 2: Treating prompts as the only lever. Workflow design and data quality usually have a greater impact than prompt tuning.
- Pitfall 3: Ignoring permission inheritance. Unauthorized read/write by an agent is a high-frequency source of production incidents.
- Pitfall 4: Delayed evaluation. Launching first and adding evaluation later makes it impossible to tell whether each subsequent change is an improvement or a regression.
8. Conclusion
Releasing models and agents together essentially binds “capability” to “delivery form.” For technical teams, what truly needs to be built is the middle layer from model to business: clear orchestration contracts, controllable tool boundaries, a measurable evaluation system, and an observable runtime environment. Doing these four things solidly means that every model iteration immediately delivers value on the business side. That is the real meaning of co-evolution.
