Software Agent Architecture and Engineering Implementation: A Practical Guide

    This article explains what software agents are and how to build them for production. It covers the core behavioral traits of agents, a four-layer reference architecture with a closed-loop control pattern, and key capabilities such as context and protocol standardization, tool calling with permission boundaries, layered memory, and multi-agent collaboration. It also outlines reliability and security governance practices and a four-stage adoption roadmap, helping developers move agents from demos to stable, observable, and cost-controlled systems.

    1. From Concept to Engineering: What a Software Agent Actually Is

    A software agent is an agent that exists in software form. It runs inside a computing process and achieves user-defined goals by perceiving the external environment, making decisions, and taking actions. What sets it apart from a one-off script is its goal orientation and continuous autonomy. Instead of orchestrating every step, developers describe the goal and constraints, and the agent plans the path, selects tools, evaluates results, and retries on failure on its own.

    Four behavioral traits are widely recognized in the research community:

    • Autonomy: completing subtasks independently without human intervention, with internal state and policy.
    • Reactivity: responding promptly to changes in the external environment, such as API responses, data updates, and new user instructions.
    • Sociality: collaborating with other agents and humans through messages and protocols.
    • Proactiveness: taking the initiative toward the goal rather than only reacting.

    The term was included in the third edition of an authoritative dictionary of computer science and technology terminology in 2018, which shows that it has moved from a research concept to a common engineering term. The real turning point, however, came with standardization and commercialization. In late 2024, the industry saw a context protocol designed for model integration. In 2025, an open protocol for agent-to-agent collaboration was released. By 2026, a standard for model and hardware coordination entered research preview. For developers, this means the interface layer is converging, and the engineering focus is shifting from getting a single demo to work to operating a system reliably.

    2. Reference Architecture: Four Decoupled Layers and Closed-Loop Control

    A maintainable agent system should be split into four layers so that prompts, business logic, and infrastructure do not get mixed together.

    1. Access layer: session entry points, authentication, quotas, and rate limiting.
    2. Orchestration layer: task planning, context management, tool selection, and multi-agent collaboration.
    3. Capability layer: model inference, retrieval augmentation, code execution sandboxes, and structured data access.
    4. Platform layer: container platform, object storage, message queues, logging services, and monitoring and alerting.

    Closed-loop control is the essence of an agent and can be abstracted as follows:

    1. def agent_loop(goal, ctx, tools, policy, max_steps=12):
    2. for step in range(max_steps):
    3. plan = policy.plan(goal, ctx) # Decide: what to do next
    4. if plan.is_done:
    5. return plan.result
    6. obs = []
    7. for call in plan.tool_calls: # Act: invoke tools
    8. obs.append(tools.invoke(call, ctx))# Perceive: collect observations
    9. ctx = ctx.update(plan, obs) # Memory: compress and persist
    10. if policy.should_abort(ctx, step): # Safety: budget and risk circuit breaker
    11. return ctx.partial_result()
    12. return ctx.partial_result()

    Three points deserve special attention in engineering: step budgets, context compression, and failure recovery. Without any one of them, the system will lose control during long-running tasks.

    3. Key Capabilities

    3.1 Context and Protocol Standardization

    On the model side, a context protocol addresses how to deliver external data and tools to the model in a unified structure. An agent-to-agent protocol addresses how to discover the capabilities of other agents, negotiate tasks, and exchange results. The engineering benefit is decoupling: models become replaceable, tools become reusable, and cross-vendor collaboration becomes feasible. The practical recommendation is to build the protocol adaptation layer as a separate module that uses your own domain models internally and converts through adapters externally, so protocol details do not leak into business code.

    3.2 Tool Calling and Permission Boundaries

    Tools are the only channel through which an agent reaches the real world, so they must follow the principle of least privilege: prefer read-only access, require a second confirmation for write operations, and route sensitive operations through an approval workflow. Tool descriptions should clearly state the input schema, side effects, idempotency, and timeout so the model can select them correctly.

    1. {
    2. "name": "query_order",
    3. "input_schema": {"order_id": "string", "fields": "array"},
    4. "side_effect": "none",
    5. "idempotent": true,
    6. "timeout_ms": 3000
    7. }

    3.3 Layered Memory

    Short-term memory holds the trajectory of the current task. Long-term memory holds user preferences and domain knowledge, usually combining vector retrieval with structured storage. The key is the write policy and the forgetting policy; otherwise, memory will pollute decision-making.

    3.4 Multi-Agent Collaboration

    Complex tasks can be split into planner, executor, and reviewer roles that communicate asynchronously through message queues. Collaboration must define termination conditions and conflict arbitration rules to prevent endless conversations and diffusion of responsibility.

    4. Reliability and Security Governance

    • Observability: trace every tool call across the full chain, and record prompt versions, model versions, latency, and token consumption.
    • Evaluation: build an offline test set and online canary releases, focusing on task success rate, rework rate, and human takeover rate.
    • Cost control: cache repeated requests, compress context, and route requests to models of different sizes by difficulty.
    • Security: filter both inputs and outputs, isolate code execution in sandboxes, manage keys through a dedicated service, and keep audit trails.
    • Human in the loop: require human confirmation for high-risk actions and keep a one-click rollback.

    5. Implementation Roadmap

    In the first stage, build a single agent with a small set of read-only tools to validate the value loop. In the second stage, add retrieval augmentation and memory, and connect approval and audit. In the third stage, split into multi-role collaboration and integrate an agent-to-agent protocol for cross-system coordination. In the fourth stage, move toward integrating agents into software development, testing, and operations pipelines, forming reusable software agent assets. Baidu AI Cloud can provide the underlying support for the architecture above through general capabilities such as its container platform, logging service, and monitoring and alerting, but the architecture design itself should remain neutral and portable.

    Conclusion

    The focus of competition in software agents has shifted from model capability alone to protocol compatibility, tool governance, and operational systems. Only when the closed loop, budgets, permissions, and evaluation are solid can an agent move from a demo to production.