Building AI Agents: A Practical Guide from Bare Bones to Full Configuration

    Many teams try a general-purpose AI agent, find it underwhelming, and blame the model. The real problem is usually an incomplete runtime stack. This guide breaks down the five capability layers a production agent needs—identity and memory, perception, expression, cost efficiency, and tool navigation—with design notes, sample role and tool contracts, a four-stage rollout plan with acceptance criteria, and common pitfalls to avoid.

    1. The Problem Is an Incomplete Stack, Not a Weak Model

    Many teams try a general-purpose AI agent, conclude that it is “not good enough,” and stop there. The complaints are usually consistent: the agent forgets everything across sessions, cannot retrieve information from outside its current context, produces only plain text, and burns through its call budget quickly. Looked at together, these are not model capability gaps. They are systemic failures caused by missing runtime components.

    A useful analogy: the model itself is the structural frame of a house, while memory, retrieval, tool calling, output channels, and quota governance are the plumbing, doors and windows, and smart-home wiring. No matter how good the frame is, the house is unlivable without them. So the optimization focus should shift from “swap in a stronger model” to “complete the engineering chain.”

    From an engineering perspective, a sustainable agent needs at least five capability layers:

    • Identity and memory: define the role boundary, and persist user preferences and prior conclusions.
    • Perception: reach external web pages and internal knowledge bases, then fetch, parse, and structure the content.
    • Expression: output in multiple forms, including text, speech, and images.
    • Efficiency and cost: compress context, reuse cached results, and route across model tiers.
    • Ecosystem navigation: register, discover, and invoke tools and resources through a single mechanism.

    2. Design Notes for the Five Core Engines

    2.1 Identity and Memory Engine

    Identity determines output style and professional boundaries; memory determines the quality of continuous collaboration. In practice, keep the two separate. Describe identity in a readable Markdown role file that covers responsibilities, input/output contracts, and prohibited actions. Split memory into three stores:

    • Factual memory: long-term user preferences, tech stack, naming conventions.
    • Episodic memory: task background, decisions made, and open questions.
    • Summary memory: rolling compressed conclusion cards from long conversations.

    For retrieval, a hybrid strategy of vector recall plus keyword recall works well. Deduplicate and resolve conflicts before writing, so stale conclusions do not overwrite newer decisions. A sketch of the structure:

    1. # Role: Backend Service Maintainer
    2. Responsibilities: API design, performance diagnosis, incident review
    3. Output contract: conclusion first + evidence + actionable steps
    4. Prohibited: capacity and billing conclusions without confirmation
    5. # Long-term memory
    6. - Tech stack: containerized deployment, centralized log collection
    7. - Preference: smallest viable change first, long-term plan second

    2.2 Perception Engine

    External information gathering falls into three scenarios: close reading of a single page, bulk collection across a site, and content that only becomes visible after interaction. In production, decouple fetching from parsing. The fetching layer handles scheduling, retries, and rate control; the parsing layer handles main-content extraction, structure normalization, and quality scoring.

    Compliance boundaries are mandatory here: collect only publicly accessible content, respect site terms and access rate limits, and never bypass paywalls or authentication. The safer engineering choice is to prefer official data interfaces or licensed data sources, treat web collection as a supplement, and tag and log every source so it stays traceable.

    2.3 Expression Engine

    Treat multimodal output as demand-driven by the task, not as a stack of capabilities. Speech recognition fits meetings and dictation; speech synthesis fits announcements and accessibility scenarios; image generation fits diagrams and prototype sketches. Package these as tool contracts that the agent selects per task, rather than hard-coding them into prompts.

    1. {
    2. "tool": "render_asset",
    3. "input": {"modality": "image|speech|text", "spec": "size/duration/tone"},
    4. "output": {"uri": "object storage address", "meta": "format and checksum info"}
    5. }

    Send all artifacts to object storage and keep only the reference address in the main text. This reduces context size and makes version management easier.

    2.4 Efficiency and Cost Engine

    Runaway cost usually comes from two habits: sending the full context every time, and calling the strongest model indiscriminately. Four measures are practical:

    • Layered context: keep the system role resident, inject task material on demand, and pass historical conclusions as summaries.
    • Cache reuse: cache retrieval results and tool outputs with a TTL.
    • Model tiering: route simple tasks like extraction and classification to lightweight models, and reasoning and generation to stronger models.
    • Output budget: cap the number of returned tool items and the text length to avoid log-style feedback into the context.

    The actual reduction depends heavily on the workload. Public experience suggests command-style long outputs offer the most obvious room for improvement, but treat that as a reference rather than a commitment, and rely on your own load test data.

    2.5 Ecosystem Navigation Engine

    Once the tool count grows, the core problem becomes picking the wrong tool. Build a unified registry where each tool declares its applicable scenarios, input/output schema, permission scope, and cost tier, and keep a list of high-risk operations that require human confirmation. That is what upgrades an agent from “can use tools” to “knows which tool to use when.”

    3. Phased Rollout and Acceptance

    • Phase 1 (1 day): write the role file and three long-term preferences. Acceptance: the agent can restate user constraints across sessions.
    • Phase 2 (2 to 3 days): connect the retrieval and summarization pipeline. Acceptance: conclusions come with verifiable sources.
    • Phase 3 (1 week): complete the multimodal output channel and object storage archiving.
    • Phase 4 (ongoing): build a cost dashboard that tracks call volume and cache hit rate by task type.

    4. Common Pitfalls

    First, assuming a longer role prompt is better; it crowds out context and dilutes constraints. Second, writing memory without ever cleaning it, which brings conflicting information back repeatedly. Third, prioritizing collection capability over compliance review. Fourth, chasing full multimodality too early while ignoring what the task actually needs.

    5. Conclusion

    The gap between “bare bones” and “fully configured” is engineering completeness, not a single model capability. Fill in the five lines—identity and memory, perception, expression, cost, and navigation—step by step, with clear acceptance metrics and compliance boundaries, and a general-purpose agent can run stably in real business over the long term. If you need a managed runtime environment, the deployment and observability work can be built on general capabilities such as the container platform, object storage, log service, and monitoring and alerting offered by Baidu AI Cloud.