LLM Selection and Engineering Practices in the Agent Era
A practical guide to selecting large language models for AI agents. It explains why public leaderboard scores often diverge from production performance, defines the key metrics that matter for agent workflows, and outlines a reproducible evaluation framework and engineering practices for reliable, cost-efficient deployments.
1. The Problem: A Systematic Gap Between Leaderboards and Real Performance
A recurring pattern has emerged in model evaluation over the past two years: some models rank at the top of public reasoning and knowledge benchmarks, yet deliver mediocre end-to-end task completion once deployed in production. Conversely, models with unremarkable scores on pure reasoning benchmarks often produce stable results in code generation, structured writing, and tool orchestration. This gap is not the result of benchmark manipulation. It is the inevitable outcome of a mismatch between evaluation goals and engineering goals.
Public leaderboards typically measure the upper bound of “single-turn, no external dependencies, one correct answer” capability. Engineering systems, by contrast, need the ability to advance tasks that are “multi-turn, dependent on external systems, and open to multiple valid paths.” Treating the former’s scores as a procurement criterion for the latter is the most common cognitive bias during model selection.
2. Core Argument: What Matters in the Agent Era Is “Driving” Tasks, Not Being Good at Everything
In an agent architecture, the model no longer performs all the work. It takes on an orchestration role: assessing the current state, choosing the right tool, parsing returned results, and deciding whether to continue or converge. The practical value of a system can therefore be abstracted into four metrics:
- Single-turn usability: the proportion of first-pass outputs that downstream components can consume directly;
- Error recovery: the recognition and successful correction of errors, timeouts, empty results, and format drift;
- Instruction adherence: strict compliance with output formats, field constraints, and prohibited items;
- Cost per task: the latency and total token consumption required to complete one end-to-end task.
An “all-around model that needs manual rework at every step” costs far more in practice than a “slightly narrower model that gets it right the first time.” This should be the primary lens for evaluating new flagship models.
3. Evaluation Framework: A Reproducible Selection Method Across Four Dimensions
3.1 Test by Mode
Reasoning and non-reasoning modes should be evaluated separately. The former excels at high-difficulty, long-chain inference; the latter has advantages in latency and consumption. A more common engineering practice is tiered routing: assign most steps to the low-latency mode and escalate only when complex constraints are detected.
3.2 Multi-Turn, Not Single-Turn
Real task scoring should be based on a triplet of “number of rounds + cumulative consumption + final success rate,” not single-turn accuracy. A schematic evaluation loop looks like this:
def run_task(model, task, tools, max_rounds=3):history, usage = [], {"tokens": 0, "rounds": 0}for r in range(max_rounds):resp = model.call(task, tools=tools, history=history)usage["rounds"] += 1usage["tokens"] += resp.usage.total_tokensif resp.action == "final" and validate(resp.payload):return {"ok": True, "rounds": usage["rounds"], **usage}history.append(resp.to_message()) # carry error messages into the next roundreturn {"ok": False, **usage}
3.3 Dedicated Instruction-Adherence Tests
Build separate test sets for format constraints, prohibited items, and field-level validation, then measure the first-pass rate. This dimension has the greatest impact on downstream parsing stability, yet it is the most frequently overlooked.
3.4 A Unified Cost Metric
Standardize pricing on “cost per thousand successful tasks,” including the sunk consumption from failed retries, to avoid being misled by unit price.
4. Engineering Implementation
4.1 Tool and Context Design
Tool descriptions should state applicable and non-applicable scenarios, parameter constraints, and error code semantics. Context should follow a “minimal sufficient” principle: inject only the information required for the current step to reduce attention dilution and format drift.
4.2 Structured Output and Validation Fallbacks
Apply schema validation to model output, and feed error messages back for a retry on failure. Introduce idempotency keys for critical write operations to prevent retries from causing duplicate side effects.
{"schema": {"name": "string", "args": "object", "idempotency_key": "string"}}
4.3 Tiered Routing and Observability
Use rules or a small model for front-end triage, and escalate complex requests. Log rounds, latency, tokens, and failure reasons across the full pipeline to build an evaluation set that supports continuous regression. These capabilities can be implemented on general-purpose infrastructure such as container platforms, message queues, object storage, and monitoring and alerting systems, without binding to a specific vendor’s APIs.
4.4 Common Anti-Patterns
Stacking all documents at once, executing model output without validation, looking only at unit price while ignoring success rate, and substituting single-turn leaderboards for scenario-based evaluation all amplify costs in production.
5. Conclusion
Evaluating a new flagship model should return to a single question: can it efficiently drive an agent to complete tasks? Build evaluation around per-mode testing, multi-turn runs, instruction adherence, and a unified cost metric; build the runtime around structured validation, tiered routing, and observability. To validate quickly in your own environment, you can use general-purpose compute, storage, and monitoring infrastructure from Baidu AI Cloud to set up a regression evaluation pipeline, and make the final decision with data rather than leaderboards.
