LLM Selection and AI Agent Deployment: Cost, Capability, and Acceptance Evaluation
This article explains how to select large language models for real engineering tasks by defining inputs and acceptance criteria first, then estimating cost per task rather than comparing price lists. It covers how input type shapes the candidate pool, why million-token context claims differ in practice, how reasoning tokens consume the output budget, and how to evaluate tool calling and failure attribution for AI agents. Readers will find a practical evaluation loop, a cost model based on actual token usage, and a general architecture for running repeatable model evaluations.
1. The Problem: Why the Same Task Can Cost Two Orders of Magnitude More
In real engineering work, tasks such as reading files, writing code, and calling tools look homogeneous, yet a single round with different models can cost anywhere from a few cents to several yuan. The root cause is not the unit price alone, but three underestimated variables: input size, output budget, and whether thinking (chain of thought) consumes the generation quota.
So the first principle of selection is not to read the price sheet, but to define what the input is and what the acceptance criteria are, then work backward to the cost. Treating specifications as a ranking of effectiveness is the most common mistake in model selection.
2. Define Input and Acceptance First, Then Talk Cost
2.1 Input Type Determines the Candidate Pool
Multimodal capability should be assessed in layers:
- Plain text plus image understanding: the broadest coverage, supported by most general-purpose models;
- Direct video understanding: capability varies widely, so it should be a hard filtering condition;
- Plain text structured tasks: long-context stability and output format compliance matter more.
A practical filtering order: first eliminate candidates using “supports direct video input” as the test, then establish a baseline with “batch image-text throughput and cost,” and finally add candidates with a larger generation budget to the pool for complex tasks.
2.2 Acceptance Criteria Must Be Quantifiable
Acceptance cannot stop at “feels smarter.” Actionable metrics include first-pass rate, tool call parameter accuracy, average number of rework rounds, end-to-end cost per task, and timeout rate. Only when these metrics are written into an evaluation script does selection have a basis.
3. Context and Output Budget: The Two Most Misread Numbers
3.1 A Million-Token Context Does Not Mean “Stuff the Input and Then Generate”
Several models claim million-token context, but the definitions differ: some approximate by characters, others count tokens; some separate maximum input from the total window, others share one window between input and generation. In engineering, budget against “total window = input + generation in this round” to avoid failures caused by truncation near the limit.
3.2 The Output Budget Includes Thinking Consumption
Thinking mechanisms make the chain of thought share the generation quota with the final answer. In other words, the stated maximum output does not equal the final answer length. For long-form generation tasks, prioritize candidates with a “larger single generation budget” and reserve headroom for the chain of thought.
Illustrative budget check logic:
def fits_window(prompt_tokens, max_output, reserved_ratio=0.2):# Reserve a ratio for chain of thought and system overheadusable_output = int(max_output * (1 - reserved_ratio))return prompt_tokens + usable_output
4. What Matters for AI Agents: Tool Calling and Failure Attribution
Names like “Max/Flash/Pro” only indicate positioning; they do not prove agent success rates. The real difficulty of tool calling lies in parameter structure compliance, error recovery, and multi-turn state consistency. For evaluation, build the same task set covering three action types: reading files, modifying code, and calling external APIs, and record which stage the failure occurred in: understanding, planning, calling, or validation.
Recommended unified evaluation loop:
- Fix the task set and acceptance script;
- Record tokens and latency for each round;
- Track first-pass rate and rework rounds;
- Rank by end-to-end cost rather than unit price.
5. Cost Model: Converting “Unit Price” into “Cost per Task”
Cost per task ≈ input tokens × input unit price + actual generated tokens × output unit price. Actual generated tokens are often significantly higher than the final answer length because of thinking modes. As a result, a cheap model that frequently needs rework may cost more per task than a more expensive model that passes on the first try. Use replay measurements on historical real traffic rather than estimates based on theoretical maximums.
6. Deployment Advice and a General Architecture
Architecturally, you can put model access behind a unified gateway, use object storage to keep corpora, a message queue to smooth task peaks, and a container platform to host the evaluation pipeline, with logging and monitoring with alerts to observe cost and failure rates. If a managed model service is needed, Baidu AI Cloud’s related products can be one general-purpose capability option, but the selection conclusion should still rest on re-testing with your own task set.
Final conclusion: filter candidates by input type first, then measure first-pass rate and end-to-end cost with a unified task set, and only then compare unit prices. Specifications are the starting point; re-testing is the basis for the decision.
