Selecting and Evaluating Foundation Models for Long-Horizon AI Agents

    Public leaderboards are useful reference points, but they are not enough for choosing a foundation model for long-horizon agents. This article presents a practical evaluation framework covering computer use, software engineering, reasoning, scientific analysis, cost, context windows, reproducibility, safety boundaries, and deployment decisions. It also explains how to compare models under consistent conditions and build a cost-effective evaluation environment in Baidu AI Cloud.

    1. Why Model Selection Should Not Rely on Leaderboards Alone

    Public evaluations of foundation models typically focus on a limited set of tasks. Different organizations may use different test sets, prompt templates, tool permissions, and numbers of runs. Comparing scores directly can therefore lead to misleading conclusions. A difference of a few percentage points on one leaderboard may have little practical impact in a real business environment—or the result may even reverse when the task distribution changes.

    When selecting a model, engineering teams should break the decision into three questions:

    1. What types of tasks can the model complete?
    2. What is its success rate in the team’s own environment?
    3. What is the total cost per completed task?

    2. Four Core Capabilities of Long-Horizon Agents

    A long-horizon agent operates autonomously across multiple steps and extended periods of time. It must plan, call tools, recover from errors, and adjust its approach. These capabilities can be evaluated across four dimensions.

    2.1 Graphical User Interfaces and Computer Use

    These tasks require an agent to interpret screen states, locate controls, fill out forms, transfer information between applications, schedule events, and perform similar actions. Key metrics include:

    • Task completion rate: Whether the agent reaches the defined end-to-end acceptance criteria;
    • Step efficiency: The number of actions and the time required to complete the same task;
    • Authorization boundaries: Whether the agent performs actions that the user did not authorize, such as deleting data or opening unrelated pages.

    The last metric is particularly important in enterprise environments. A model with a slightly lower success rate but no boundary violations is often more suitable for production than a model with a higher success rate that occasionally performs unauthorized actions.

    2.2 Software Engineering and Terminal Operations

    Code-related evaluations should use real repositories rather than isolated algorithm problems. A typical workflow may require the agent to understand an existing codebase, locate defects, modify multiple files, run tests, and iterate based on failure messages.

    Recommended metrics include:

    • The percentage of tasks that pass tests after the first modification;
    • The model’s ability to correct its work after receiving human guidance;
    • Whether it takes shortcuts, such as modifying or deleting test cases merely to make them pass;
    • The number of manual rework cycles required during code review.

    2.3 Mathematics and Abstract Reasoning

    These tasks are useful for estimating a model’s upper bound in rule induction and multi-step logical deduction. Evaluators should first determine whether the questions may have appeared in the model’s training data. Whenever possible, use internally created problems or deduplicated test sets.

    For research-assistance scenarios, the evaluation should also check whether intermediate reasoning can be verified, rather than assessing only the final answer.

    2.4 Scientific Research and Data Analysis

    Research-oriented tasks often involve literature search, experimental data processing, and hypothesis validation. The primary focus should be traceability:

    • Do the cited data and sources actually exist?
    • Can the calculations be reproduced?
    • Does the model explicitly report missing data instead of fabricating values?

    3. Evaluating Cost and Context Windows

    Model pricing is commonly based on input and output tokens per million tokens. Some services also offer discounted rates for cached input. Looking only at the listed unit price can underestimate the real cost because long-horizon tasks repeatedly resend context, while output length increases as the number of steps grows.

    A practical estimate is:

    1. Per-task cost = Input tokens × Input price
    2. + Output tokens × Output price
    3. + Cached input tokens × Cached input price

    Token usage should be collected from real task logs rather than estimated from sample text.

    The context window determines whether a complete codebase or long document can be included in a single request. However, a larger context window does not mean every request should fill it. In practice, retrieval, summarization, and segmented calls can help control input size.

    4. Building a Reproducible Evaluation Process

    Model-selection conclusions should come from A/B tests conducted under consistent conditions. The following is a general evaluation framework that can be adapted to the team’s technology stack:

    1. Input: TASKS, a business task set with at least 30 tasks per category
    2. MODELS, a list of candidate models
    3. SANDBOX, an isolated execution environment with no production-data access
    4. for task in TASKS:
    5. for model in MODELS:
    6. for run_id in 1..N: # Repeat runs to reduce the impact of randomness
    7. result = run_agent(
    8. model=model,
    9. task=task,
    10. env=SANDBOX,
    11. max_steps=task.step_limit,
    12. )
    13. record(
    14. task_id=task.id,
    15. model=model,
    16. success=result.passed,
    17. duration=result.elapsed,
    18. input_tokens=result.usage.input,
    19. output_tokens=result.usage.output,
    20. human_fixes=result.human_interventions,
    21. out_of_scope=result.unauthorized_actions,
    22. )
    23. Summary: Calculate success rate, median duration, and per-task cost
    24. by task category.
    25. Report confidence intervals for success rates. If the intervals
    26. overlap, treat the difference as statistically insignificant.

    The evaluation should meet the following requirements:

    • Keep prompts, tool lists, timeout settings, and permission configurations consistent across all candidate models;
    • Use anonymized or synthetic data to prevent the disclosure of business information;
    • Save complete logs for every run to support later auditing and review;
    • Repeat each task multiple times because agent behavior is probabilistic.

    5. A Decision Framework for Model Selection

    Evaluation results can be mapped to the following decision table:

    Business scenario Primary metrics Decision guidance
    Cross-application office automation Completion rate, unauthorized actions Zero unauthorized actions should be a launch prerequisite
    Repository-level code changes First-pass rate, rework count Assess together with code-review costs
    Advanced reasoning and rule induction Accuracy, verifiability of reasoning Check carefully for test-set leakage
    High-concurrency, lightweight calls Unit cost, latency Cache hit rate can have a significant impact

    In production, a tiered strategy can be effective. Use a more reliable model for high-risk, high-value tasks, and a lower-cost model for low-risk, high-volume workloads. Routing rules can then switch between the two according to task requirements.

    6. Common Mistakes

    Treating a Single Demo as Proof of Capability

    Demonstrations are usually selected in advance and do not represent average performance.

    Ignoring the Cost of Human Fallback

    A small improvement in completion rate may not increase overall efficiency if every result still requires manual review.

    Comparing List Prices Only

    After accounting for retries and context length, a solution with a lower unit price may have a higher total cost per task.

    Using Identical Prompts for Every Model

    Different models have different sensitivities to instruction formats. Reasonable prompt adaptation should be performed for each model, and the adaptation method should be documented in the evaluation report.

    7. Running Evaluations in Baidu AI Cloud

    When building an evaluation environment on Baidu AI Cloud, enterprises can use general capabilities such as permission isolation, access auditing, and log retention to separate the evaluation sandbox from production networks. For long-running evaluation workloads, elastic allocation of computing resources can help control costs.

    Available capabilities and configuration details may change, so teams should consult the official documentation and current pricing information.

    8. Conclusion

    Selecting a model for long-horizon agents is primarily an engineering problem. Teams should first decompose business tasks into measurable capability dimensions, collect real performance data under consistent conditions, and then make decisions based on safety boundaries and cost structures.

    Public leaderboards can provide useful reference points, but the final decision should be based on the team’s own business scenarios.