AI Agent Selection and Implementation: A Practical Guide for Developers
This guide explains how to select and deploy AI agents for real engineering work. It defines agents as execution units built on LLMs with tool use, memory, orchestration, and verification; classifies them into conversational, code-generation, tool-orchestration, and platform-embedded types; and outlines common paid lessons around compliance risk, wrapper tools, subscription waste, and built-in assistants. It then provides a five-dimension scoring framework, a tiered test-suite design method, engineering practices for context layering, tool calls, and human approval gates, cost-control tactics, and optional self-hosted or cloud deployment paths.
1. First, Correct a Common Assumption: An Agent Is Not a Longer Chat Window
Many developers begin by treating an AI agent as a “search engine that chats better.” They spend weeks jumping between products and conclude that “they are all about the same, each with its own pitfalls.” This trial-and-error approach is not worthless, but it is expensive and produces little reusable knowledge.
A more accurate understanding is this: an AI agent is an execution unit built on a large language model as its reasoning core, augmented with tool calling, state memory, task orchestration, and result verification. Its value lies not in “answering like a human” but in “completing a multi-step task and delivering a verifiable output.”
Therefore, the first principle of selection is not “which model is smarter,” but: which category of work am I handing over to it, and how much am I willing to pay for its mistakes?
2. Four Categories of Agents by Work Type
1. Conversational Assistants
Used for consultation, document understanding, and draft proposals. These are single-turn or short multi-turn interactions with no side effects and low error costs. They are sensitive to general reasoning and expression quality and place almost no demands on toolchains.
2. Code-Generation Agents
Covering completion, single-file generation, cross-file refactoring, and test writing. The key metric is not “can it write code” but repository-level understanding under long context, adherence to existing code style, and whether it introduces changes that fail to compile or cause dependency conflicts. These agents must have an executable feedback loop: code can be compiled, tested, and debugged immediately after it is written.
3. Tool-Orchestration Agents
Calling external capabilities such as retrieval, databases, message queues, container platforms, and monitoring/alerting to perform business actions. The core risk escalates from “wrong answer” to “wrong operation,” so permission granularity, idempotent design, and approval checkpoints matter more than model capability.
4. Platform-Embedded Assistants
Assistants embedded in office suites, collaboration tools, or cloud consoles. Their advantage is natural proximity to data and process context; their limitation is limited customization and difficulty supporting complex engineering pipelines.
3. Four Common “Paid Lessons”
Most developers spend their first tuition on the following four cognitive biases:
Underestimated compliance risk. Some overseas services carry uncertainties such as account bans, regional restrictions, and cross-border data transfer. More seriously, their terms of service and content policies may conflict with the user’s values. Once production workflows depend on them, the cost of interruption far exceeds the subscription fee.
The ceiling of wrapper tools. “Coding agent shells” built by wrapping third-party APIs perform impressively on simple scripts, but expose rough context-window management, short tool-call chains, and inability to integrate with existing pipelines when facing cross-module refactoring. They solve “demo effect,” not “engineering throughput.”
High-frequency waste of subscriptions. High-priced plans deliver minimal marginal value if daily usage is low. What really needs to be calculated is “cost per valid output”:
# Cost per valid output estimationcost_per_valid_output = period_fee / valid_outputs# valid_outputs: outputs that pass review/compilation/testing, not generation counts
The boundaries of built-in assistants. Built-in office-platform agents are suitable for information summarization and process triggering, but their limits appear quickly when tasks require cross-system reads/writes, long-running execution, or version management.
4. Building Your Own Selection Framework
Use five dimensions for quantitative scoring, 1–5 points each; a total below 18 does not enter the production pipeline:
| Dimension | Key Question |
|---|---|
| Context capability | Can it stably handle repository-level/document-level long text without dropping constraints midway? |
| Tool ecosystem | Does it support function calling, MCP-style protocols, and custom plugins? |
| Feedback loop | Can it execute commands, read logs, and self-retry/correct? |
| Operability | Are there audit logs, usage statistics, and permission/quota controls? |
| Compliance and stability | Where is data stored, what are the terms, and what is the account sustainability risk? |
The most overlooked is “operability.” Once an agent enters daily team use, a system that cannot trace “who had it do what and when” will struggle to pass security review.
5. Designing Evaluation Test Cases
Subjective impressions are unreliable; a fixed test set is required. Prepare 20–30 tasks from real work covering three difficulty levels:
- L1 single-point tasks: generate a utility function, explain an error message, convert API docs into type definitions.
- L2 multi-step tasks: add and pass unit tests for an existing module; add a cache layer to a legacy API without breaking callers.
- L3 open-ended tasks: locate an intermittent concurrency defect; split an order module from a monolith into an independent service.
Scoring should use pass rates rather than aesthetics:
L1 pass criteria: first-pass rate >= 85%, with no manual editsL2 pass criteria: pass within two iterations >= 70%L3 pass criteria: provide a verifiable troubleshooting path >= 50%
Re-run the same suite quarterly. Models iterate quickly, and conclusions from six months ago are often already obsolete.
6. Three Engineering Practices for Using Agents Well
1. Layer Prompts and Context
Do not pile all information into one conversation. Recommended layered injection:
[System layer] Role, output format, prohibited actions[Project layer] Tech stack, directory conventions, code-style summary[Task layer] Specific requirements, acceptance criteria[Evidence layer] Relevant file snippets, error logs, API definitions
Also make explicit that “when uncertain, it must ask or label assumptions,” which significantly reduces rework caused by hallucination.
2. Replace Long-Text Guessing with Tool Calls
When facts are needed, have it look them up rather than answer from memory. A typical toolset includes: searching the codebase, running builds and tests, querying monitoring metrics, reading log services, and operating object storage. The core principle is “read more, write less; every write leaves a trace.”
3. Set Human-AI Collaboration Brakes
Insert mandatory human confirmation before actions that delete data, modify production configuration, execute database changes, or send external messages. In engineering terms, this can be implemented as tiered permissions: read-only mode -> sandbox write mode -> controlled production mode.
7. Four Cost-Control Tactics
- Tiered routing: simple tasks go to lightweight models, complex reasoning goes to flagship models, with rules or a small model as a front-end discriminator.
- Context slimming: inject only the snippets required for the task; summarize or index long documents before retrieval.
- Caching and reuse: solidify high-frequency prompts and structured output templates to reduce repeated consumption.
- Quotas and alerts: set usage caps for teams and projects, and surface abnormal growth promptly through monitoring alerts.
8. Optional Self-Hosted and Cloud Deployment Paths
If usage scales up, consider building a controllable agent platform on general cloud capabilities. A typical combination is:
- Model service: access models of different sizes through a unified model-invocation gateway for easy replacement and canary rollout.
- Container platform: host the agent runtime and tool sandboxes for elastic scaling and isolation.
- Object storage: store knowledge-base files, build artifacts, and runtime snapshots.
- Message queue: decouple long-running tasks and support async execution and retries.
- Log service + monitoring/alerting: enable full-chain tracing, cost accounting, and anomaly localization.
Baidu AI Cloud can provide corresponding foundational capabilities in these general categories. Enterprises can choose public cloud or private deployment based on their own compliance requirements and data-residency policies, avoiding lock-in to a single vendor.
9. Conclusion
The essence of selection is not finding the “strongest agent” but building a usage system where “capability is testable, cost is controllable, and risk is auditable.” Three implementation recommendations for developers:
- First clarify the task type, then score across the five dimensions of context, tools, feedback loop, operability, and compliance;
- Build a fixed test-case suite and re-run it quarterly, replacing impressions with data;
- Integrate agents into the existing R&D pipeline rather than letting them float outside the engineering system.
With these three points, the previous “tuition” is no longer a sunk cost but becomes a reusable evaluation asset for the team.
