Enterprise AI Agents at Scale: A Technical Path to Production
This article outlines a practical engineering path for scaling enterprise AI agents from single-point copilots to a reusable agent matrix. It covers scenario layering, a six-layer reference architecture, knowledge base integration with permission-aware retrieval, context engineering, tool calling and task planning, entry-point integration, governance and evaluation, common anti-patterns, and a phased rollout plan. The focus is on how to replicate agents on a shared runtime while ensuring retention, control, and operability.
1. From Single-Point Copilots to an Agent Matrix
A notable shift in the industry is that application teams have shipped a large number of general-purpose and vertical agents in a short period, covering knowledge management, document collaboration, browser and input method entry points, maps and travel, marketing, and contract signing. Setting aside specific product names, this trend reflects the convergence of three technical curves:
- Falling inference costs and higher throughput for large models make it engineering-feasible to call a model on every interaction.
- Mature engineering for knowledge bases and vector retrieval makes private-domain knowledge reliably retrievable.
- Standardized tool calling (Function Calling / Tool Use) and structured output move models from “talking” to “doing.”
For developers, the question worth studying is not how many agents a given vendor has launched, but how to replicate agents quickly on a unified foundation while ensuring retention, control, and operability.
2. Scenario Layering: The Boundary Between General and Vertical Agents
Classifying agents along two dimensions, task determinism and how private the knowledge is, yields clear engineering strategies:
- High generality, low privacy: companion assistants (input assistance, voice transcription, search Q&A). The focus is low latency and entry-point integration.
- Medium generality, medium privacy: document and knowledge base assistants. The focus is retrieval quality and permission consistency.
- Low generality, high privacy: marketing, contract, and industry workflow agents. The focus is workflow orchestration, tool integration, and auditing.
After layering, the platform needs to provide “one runtime plus pluggable capability packages” to avoid rebuilding the wheel for every scenario.
3. Reference Architecture: A Six-Layer Structure
- Entry layer: multi-channel access (mobile, desktop, browser, plugins, input methods) with a unified session protocol.
- Orchestration layer: a Planner plus an Executor, supporting multi-step tasks and fallback.
- Capability layer: a tool registry, retrieval service, code and spreadsheet execution sandboxes, and connectors to external systems.
- Knowledge layer: document parsing, chunking, vectorization, incremental sync, and permission labels that travel with documents.
- Model layer: a general large model plus small-model routing (intent classification, rewriting, voice), split by cost and latency.
- Governance layer: identity and permissions, audit logs, quotas and rate limiting, monitoring and alerting, and canary releases.
General-purpose capabilities from Baidu AI Cloud (such as object storage, message queues, container platforms, log services, monitoring and alerting, and key management) can serve as the underlying foundation, but the architecture itself is vendor-neutral.
4. Connecting the Knowledge Base: The First Principle of Retention
The essence of “high retention within less than two months of launch” is that the agent connects to the knowledge carriers users actually use every day. Key engineering points:
- Unified document model: abstract local files, online documents, team knowledge bases, and personal knowledge bases into a unified Resource{uri, mime, acl, version}.
- Incremental sync: trigger incremental indexing based on version numbers or change events to avoid full rebuilds.
- Permissions travel with documents: apply ACL filtering before vector recall during retrieval to prevent unauthorized recall.
- Multi-path recall fusion: keyword search (BM25) plus vector search plus metadata filtering, followed by reranking.
Illustrative code (pseudocode, expressing the flow only):
def retrieve(query, user_ctx, top_k=20):candidates = []for res in list_resources(user_ctx):if not acl_check(res, user_ctx): # Authenticate firstcontinuecandidates += bm25_search(res, query)candidates += vector_search(res, query)merged = dedup(candidates)return rerank(merged, query)[:top_k]
5. Context Engineering: What Makes It Feel Like a Team
An agent’s usability depends roughly 80% on context organization rather than the model itself. A recommended structure:
- System constraints: role, boundaries, refusal policy, and output format.
- Long-term memory: user preferences and a project glossary, stored as compressed summaries.
- Session memory: the most recent N turns verbatim plus summaries of earlier turns.
- Retrieval context: chunks with source and timestamp, with mandatory citation.
- Tool results: structured JSON with error codes and retryable flags.
A practical template:
[Constraints] Answer only based on the provided material; state gaps when uncertain.[Glossary] Project code names and business definitions follow the glossary.[Material] {{retrieved_chunks_with_source}}[Tools] {{tool_results_json}}[Output] Conclusion first, then evidence, then suggested next steps.
6. Tool Calling and Task Planning: From Demo to Production
A production-grade agent must assume that tools will fail. Engineering principles:
- Contract-based tools: each tool declares its name, input schema, timeout, idempotency, and side-effect level.
- Plan-execute-verify loop: the Planner produces steps, the Executor runs them, and a Verifier checks whether the result meets the goal; on failure, fall back or switch paths.
- Idempotency and compensation: write operations use idempotency keys; cross-system operations introduce a message queue for eventual consistency.
- Sandbox isolation: run code and spreadsheet execution in container sandboxes with restricted network and file system access.
{"name": "create_contract_draft","schema": {"template_id": "string", "parties": "array", "amount": "number"},"timeout_ms": 8000,"idempotent": true,"side_effect": "write"}
7. Entry-Point Integration: Engineering Constraints for Companion Agents
Browsers, input methods, maps, and similar entry points share the same traits: low latency and strong context. Key points:
- On-device small models handle intent detection and rewriting, while cloud-based large models handle complex reasoning, forming tiered routing.
- Page or scenario context is injected as a structured summary to avoid overly long raw text.
- Streaming output and interruptible generation, with time to first token kept in the hundreds of milliseconds (subject to actual load testing).
- Privacy first: input content is desensitized on the device before being sent.
8. Governance and Evaluation: Operability Is What Makes Replication Possible
- Permission consistency: agents inherit the caller’s permissions; “super account” style services are prohibited.
- Auditing: record prompt versions, retrieval sources, and tool call chains to support traceback.
- Evaluation system: task success rate, citation accuracy, unauthorized recall rate, average number of steps, cost per task, and seven-day retention.
- Canary and rollback: canary by scenario and tenant, keeping the ability to roll back to the previous prompt and tool set version with one click.
9. Common Anti-Patterns
- Cramming all logic into one extremely long prompt, making it untestable and non-rollbackable.
- Vectorizing before authentication, creating unauthorized access risk.
- Tools without idempotency design, producing dirty data on repeated execution.
- Evaluating only whether the answer “sounds right” rather than whether the task is completed.
- Ignoring cost by skipping small-model routing and caching.
10. Recommended Rollout Path
- Phase 1: pick a high-privacy, high-frequency scenario (such as knowledge Q&A) and connect retrieval and permissions.
- Phase 2: abstract a tool registry and orchestration runtime, then replicate a second scenario to validate reuse.
- Phase 3: complete governance (auditing, quotas, canary) and an evaluation dashboard.
- Phase 4: extend to entry points with tiered routing and latency optimization.
Conclusion: Competition among agent matrices ultimately comes down to three things: the depth of knowledge integration, the engineering quality of context, and the maturity of tool governance. Turning these three into platform capabilities is what makes it possible to continuously and cost-effectively replicate general and vertical agent applications on the same foundation.
