A Practical Guide to Building AI Agents That Take Action
This article explains how AI is shifting from conversational question answering to action-taking agents, and what that shift means for engineering teams. It breaks down the core capabilities an agent needs, including task planning, standardized tool calling, externalized state, and multi-agent collaboration, then presents a five-layer agent runtime reference architecture. It also covers permission and security boundaries, task-level evaluation metrics, and typical use cases, with practical advice on starting from a narrow scenario and building a reversible, auditable loop first.
1. From Answering Questions to Taking Action: A Shift in Technical Paradigm
Over the past two years, the dominant form of large model applications has been conversational question answering: a user asks a question, the model generates text, and the interaction ends within a single turn or a few turns. The core direction of the new generation of technical evolution is to give models the ability to take action—that is, to autonomously plan steps within an authorized scope, call external tools, pass intermediate results between multiple stages, and remain accountable for long-horizon goals.
This shift is not simply a matter of “adding features,” but a fundamental change in engineering constraints:
- Interaction moves from a “single request–response” to a task session that can last tens of minutes or even hours;
- Failure modes shift from “wrong answers” to interruption halfway through execution, irreversible tool side effects, and context overflow;
- Evaluation moves from “text similarity” to whether the task is actually completed and whether the cost is reasonable.
As a result, the focus of building agent systems has shifted from prompt engineering techniques to the design of the Agent Runtime.
2. Capability Breakdown: What an Action-Taking Agent Needs
2.1 Task Planning and Decomposition
An agent needs to break a vague goal into verifiable subgoals. A common engineering approach is a three-stage “plan–execute–review” flow: first produce a structured plan (including dependencies), then execute it step by step, and finally self-check the results. The plan should not be plain text, but a verifiable data structure that makes mid-course reordering and failure rollback easier.
2.2 Tool Calling and Protocol Standardization
The ability to act depends on tools. The industry commonly adopts a calling paradigm of “tool description + structured input + structured output,” abstracting tool capabilities into an enumerable list of interfaces, with the model selecting them and the runtime validating parameters and executing them. The key lies in parameter validation and idempotency design: write operations need an idempotency key to avoid duplicate side effects caused by retries.
2.3 Long Context and Externalized State
Long-horizon tasks inevitably exceed the context window. A workable approach is to externalize state: store the task tree, intermediate artifacts, and logs in persistent storage separately, and have the model load only the “currently relevant slice” each time. A sample structure is shown below:
{"task_id": "t-1024","goal": "Complete the quarterly data audit and output a report","plan": [{"id": "s1", "action": "collect", "status": "done"},{"id": "s2", "action": "reconcile", "status": "running", "deps": ["s1"]},{"id": "s3", "action": "report", "status": "pending", "deps": ["s2"]}],"artifacts": ["oss://bucket/t-1024/raw.csv"],"budget": {"tokens": 180000, "wall_clock_min": 25}}
2.4 Multi-Agent Collaboration
Complex tasks can be split among multiple sub-agents working in parallel: one handles retrieval and evidence gathering, one handles code changes, and one handles review and validation, while the main agent only handles scheduling and conflict resolution. The success of collaboration depends on three things: whether task boundaries are clear, whether shared state is versioned, and whether conclusions can be independently verified.
3. Runtime Architecture: A Five-Layer Reference Design
- Access Layer: A unified session entry point that handles requests from web, mobile, and internal systems, and is responsible for authentication and quotas.
- Orchestration Layer: Task parsing, plan generation, sub-agent scheduling, and retry and fallback strategies.
- Execution Layer: Tool sandboxes, code execution environments, and isolated zones for side effects such as browser and file operations.
- State Layer: Task metadata, vector retrieval indexes, intermediate artifacts in object storage, and asynchronous events in message queues.
- Observability Layer: Distributed tracing, metrics monitoring, log aggregation, and alerting, supporting cost attribution and failure localization.
When implemented on the cloud, the layers above can map to general capability categories: object storage for artifacts, message queues to decouple long-running tasks, container platforms to host sandboxes, and logging services with monitoring and alerting to ensure observability. General cloud product categories from Baidu AI Cloud can serve as the underlying foundation for such an architecture.
4. Permissions, Security, and Compliance: The Boundaries of Action
Once a model can “take action,” the security model must be upgraded from “content filtering” to “behavior control”:
- Least privilege: Each tool is granted only the read/write scope necessary to complete the task, with credentials issued temporarily per task.
- Sandbox isolation: Code and commands run in restricted containers, with limits on network egress, the file system, and resource duration.
- Human in the loop: Irreversible operations (deletion, transfers, external publishing) require a second confirmation, and rollback snapshots are retained.
- Full audit: Record “who called which tool, when, and with what parameters,” forming an accountable chain.
- Data boundaries: Sensitive data is masked before entering the model context, and artifacts are encrypted and stored according to classification policies.
5. Evaluation and Tuning: How to Prove It Can Actually Do the Work
Traditional text evaluation is insufficient to measure the ability to act; task-level benchmarks need to be introduced, focusing on four types of metrics:
- Task completion rate: Whether the end-to-end goal is achieved;
- Step efficiency: Whether the completion path is redundant and whether there are ineffective loops;
- Cost and latency: The compute and wall-clock time consumed per task;
- Safety violation rate: The proportion of unauthorized calls and dangerous operations.
For tuning, prioritize three things: compress ineffective context to reduce consumption, add caching and idempotency for high-frequency tools, and preset fallback paths for steps that fail easily. Engineering experience shows that for long-horizon tasks, the bulk of the cost often comes not from the model calls themselves, but from repeated trial and error and state rebuilding.
6. Typical Use Cases
- Software development: Intelligent programming tools handle a closed loop of defect localization, patch generation, and regression validation;
- Finance and audit: Multi-step reconciliation, evidence gathering for anomalous vouchers, and automatic report generation;
- Data operations: Automated setup from data extraction and cleaning to visualization dashboards;
- Personal assistants: Handling schedules, information organization, and form tasks under explicit authorization.
7. Conclusion
The essence of “being able to take action” is to turn a model from a content generator into a governable execution entity. The real competitive barrier lies not in single-point model capability, but in the runtime system composed of orchestration, state, sandboxing, and observability. It is recommended that teams start from a narrow scenario, first establish a minimal closed loop that is reversible and auditable, and then gradually expand the scope of authorization and task duration.
