Million-Token Context and AI Agents in Production: How to Choose a Large Language Model
This guide explains how to evaluate large language models for production use. It covers testing recall in long documents, reading benchmark scores, assessing code and tool-calling workflows, measuring hallucination and safety behavior, estimating monthly inference costs, and building a regression test set before launch.
Large language models are moving from conversational tools to production tools. When teams choose a model, three questions come up most often: Can the model stay accurate across long documents? Can it complete multi-step tasks reliably? Is the cost under control? Rather than relying on a single leaderboard score, this article offers a method that teams can verify themselves.
1. Long Context: Verify Recall Before Capacity
Support for a million-token context window means a model can take in large amounts of code, documents, or reports in one request, without manual chunking. However, window size does not guarantee quality. The longer the input, the more likely the model is to miss key information in the middle, or to contradict itself when reasoning across sections.
Use the following methods to verify this:
- Insert several known facts into a long text, vary their positions and the text length, then ask questions and measure the recall rate.
- Test with real cross-file tasks. For example, if an interface change requires updates in three callers, check whether the model finds all three.
- Record how input length relates to accuracy. Identify the length at which performance starts to drop noticeably, and use it as the safe upper limit for your application.
2. How to Read Evaluation Scores
Comprehensive benchmark leaderboards typically combine weighted sub-scores for knowledge question answering, logical reasoning, code generation, instruction following, and multi-turn dialogue. An overall score works for an initial screening. For a decision, look at the sub-scores. The benchmark publisher sets the weighting, and your application may depend on only two or three of these areas.
When reading a leaderboard, confirm the following:
- Whether the sub-scores match your task.
- Whether the evaluation date, model version, and prompt settings are published.
- Whether the score gap exceeds the random variation of the evaluation itself. When two models differ by only a few tenths of a point, that difference is usually not enough to justify a selection.
Evaluation scores are only a static snapshot. Prompt design, task complexity, and output stability all change real-world results, so test with your own samples before launch.
3. Code and Agents: Treat Tool Calls as Testable Workflows
The value of an agent lies in execution, not just advice. A model that can break down tasks, call tools, and adjust its strategy based on results can handle compound instructions such as “analyze the report and send it to the team.”
When evaluating coding ability, focus on three things:
- Whether the model understands multi-file project structure, not just how to write a single function.
- Whether the generated code passes compilation, unit tests, and static checks.
- Whether the changes break existing interfaces.
When evaluating tool calls, test failure scenarios, not just success paths. A common troubleshooting checklist includes:
- Insufficient permissions: The model should identify the cause of the error, stop retrying, and tell the user which permissions are needed.
- Request timeout: The model should set a retry limit, use exponential backoff, and record the task status once the limit is reached.
- Mid-task failure: Operations that involve writes should first record the completed steps. On failure, the steps should be rolled back in reverse order to avoid leaving partially completed data.
Each scenario should have clear pass criteria, such as “reaches a conclusion within three retries” or “produces no duplicate writes.”
4. Specialized Domains: Use Business Samples Instead of General Conclusions
In specialized fields such as finance, models can handle information extraction, metric calculation, and first drafts of reports. A typical workflow involves extracting key metrics from prospectuses or financial statements, building standardized tables, and then generating summaries with written analysis.
Before launch, prepare a set of manually verified samples. Compare model output against the reference answers field by field, and calculate field-level accuracy. Key figures must pass manual or rule-based verification before they enter a formal report.
5. Hallucination and Safety: Measure with Metrics
Hallucination needs continuous measurement. One approach is to build a test set with obscure or easily confused facts and calculate the factual error rate. For example, suppose a model’s factual error rate on that test set drops from 23.4% to 8.3%. The relative reduction is about 64.5%. This figure is only valid for the same test set and the same scoring criteria. To compare overall answer error rates, the statistical method and sample composition must be specified.
For safety, test both refusal and degraded behavior. For sensitive topics such as cybersecurity, a production release should consistently refuse high-risk requests or provide only defensive or educational content. Teams should record the test scope and boundaries in their test reports, rather than publishing a single success rate. If testing involves real attack capabilities, it should only be conducted in authorized environments.
6. Cost Control: Estimate with Formulas, Not Intuition
Inference cost depends mainly on the number of input tokens, the number of output tokens, and call frequency. The public prices cited in the original article are: standard version input at about 13 yuan per million tokens, and output at about 68 yuan per million tokens. The high-speed version is priced at twice the standard rate. Actual prices are set by the provider, so check the latest pricing before making a selection.
Estimate monthly cost with this formula:
Monthly cost = requests per day × 30 × (average input tokens × input price + average output tokens × output price) ÷ 1,000,000
Example: 1,000 requests per day, with 2,000 input tokens and 500 output tokens per request, at standard prices. The daily input cost is 1,000 × 2,000 ÷ 1,000,000 × 13 = 26 yuan. The daily output cost is 1,000 × 500 ÷ 1,000,000 × 68 = 34 yuan. The total is 60 yuan per day, or about 1,800 yuan per month.
Context caching suits scenarios where many requests share the same long prefix, such as repeatedly querying the same codebase. Estimate the savings with this formula:
Savings = hit count × prefix tokens × (standard input price − cache read price) ÷ 1,000,000 − extra cache write cost
Suppose the codebase prefix is 100,000 tokens and it is hit 1,000 times per day. The cache read price is estimated at 10% of the standard input price. This is an assumption, not an official price. Under that assumption, the daily savings are about 1,000 × 100,000 × (13 − 1.3) ÷ 1,000,000 = 1,170 yuan. Cache write costs must be counted separately. Caching only pays off when the hit rate is high enough.
Two other common strategies:
- Elastic scaling: Combine containers with serverless computing to release resources during low-traffic periods.
- Model routing: Send simple classification tasks to smaller models and complex reasoning to larger models. Base routing rules on accuracy from historical samples, not only on task names.
7. Minimum Checklist Before Launch
- Build a regression evaluation set. Samples should cover the real business scenarios in each category, with at least 50 samples per task type. Document how reference answers are judged.
- Define pass criteria. After each model upgrade, compare accuracy, latency, and cost per request on the same evaluation set.
- When connecting to internal systems, define parameter types and permission scopes clearly with function calling. Add manual confirmation for write operations.
- Log online failure cases. Categorize them weekly and add them to the evaluation set.
Summary
Model selection should not rely on leaderboards alone. Put long-context recall rates, pass results for code and agent workflows, hallucination rates, and the cost formula into one evaluation table. That table shows whether a model fits a business better than any single score. Model capability sets the ceiling for an application, but reproducible testing and cost estimates determine whether the project can be deployed reliably.
