Optimizing and Evaluating Foundation Models for AI Agent Workflows

    This article explains why general-purpose benchmarks fall short for AI agent workflows and outlines four optimization directions: structured tool calling, complex instruction following, scheduled and persistent tasks, and long-horizon execution with multi-agent collaboration. It introduces a four-dimension evaluation framework covering accuracy, latency, token consumption, and cost, along with practical advice for building custom evaluation sets, designing production architecture, and controlling costs. The goal is to turn model capabilities into reliable system performance for real-world agent deployments.

    1. Why General-Purpose Capabilities Are No Longer Enough

    Over the past two years, foundation model evaluation has largely focused on whether single-turn answers are accurate and whether reasoning is rigorous. Once models are placed into real business systems—especially AI agent workflows that must call external tools and execute tasks continuously across multiple steps—the evaluation criteria change fundamentally. A single task may require a model to perform ten or even dozens of operations. Any single mistake along the way—a parameter parsing error, a formatting deviation, or a state misjudgment—can break the entire chain.

    These workflows share four typical characteristics:

    • Tool-intensive: The model must understand tool descriptions, generate structured call arguments, parse return values, and decide the next step.
    • Strong instruction constraints: System prompts often contain extensive business rules, output formats, and boundary conditions.
    • Persistence: Workloads include scheduled triggers, periodic inspections, and event-driven execution over long periods, rather than one-off question answering.
    • Long chains: Tasks span many steps, context keeps accumulating, and stability and consistency requirements are far higher than for single-turn generation.

    As a result, a new model optimization approach is emerging: instead of only building a “general-purpose model plus later adaptation,” teams are treating the core requirements of agent workflows as optimization targets during both pre-training and post-training. This article discusses the technical logic and evaluation methods behind that approach.

    2. Four Technical Directions for Specialized Optimization

    2.1 Structured Tool Calling

    Tool calling is essentially a constrained generation problem: the model must select from a given set of tools and produce arguments that conform to a schema. Optimization usually focuses on three areas: semantic alignment of tool descriptions so the model can distinguish tools with similar functions; validity of generated arguments to reduce missing required fields, type errors, and out-of-range enum values; and multi-tool orchestration, meaning a reasonable combination of parallel and sequential calls within a single response.

    An illustrative call structure is shown below (a generic form, not a specific API):

    1. {
    2. "tool": "query_order_status",
    3. "arguments": {
    4. "order_id": "A20260801",
    5. "with_logistics": true
    6. },
    7. "call_mode": "parallel"
    8. }

    In practice, it is advisable to validate model output a second time: first perform structural validation against the schema; if validation fails, retry once with the error information included; if it still fails, fall back to human confirmation. This prevents invalid arguments from reaching business systems directly.

    2.2 Complex Instruction Following and Constraint Preservation

    Maintaining constraints across long prompts is a common pain point. Effective practices include layering rules (global rules, task rules, and output format rules) and restating constraints before key steps; using parseable structures rather than natural-language descriptions for output formats; and adding a self-check step so the model verifies each item against a constraint checklist before submitting.

    2.3 Scheduled and Persistent Tasks

    The difficulty of persistent tasks lies not in single-step generation but in state management. A recommended approach is to decouple scheduling from inference: an external scheduler handles triggering and timeout control, while the model is responsible only for single-step decisions. Context should be compressed in layers—“summary + key state + recent raw text”—to avoid unbounded context growth. Keeping a replayable checkpoint for each run also makes failure recovery easier.

    2.4 Long-Horizon Execution and Multi-Agent Collaboration

    Long-horizon stability depends on three things: step-level idempotent design, rollback on failure, and clear role separation. For multi-agent collaboration, a “planner–executor–verifier” structure is recommended, where the verifier independently reviews results to avoid the bias accumulation that comes from executors confirming their own work.

    3. A Four-Dimension Evaluation Framework: Measuring Real Performance

    Evaluation should cover at least four dimensions, none of which can be skipped:

    Dimension Meaning Focus
    Accuracy Proportion of correct task outcomes Broken down by dimension, not just an overall score
    Response latency Average time per call Cumulative latency in long chains
    Token consumption Average tokens per call Context growth and redundant output
    Call cost Cost per thousand calls Determined jointly by latency and tokens

    It is important to emphasize that two models with similar overall scores can differ enormously in engineering usability. A model with slightly lower accuracy but half the latency and lower token usage often has a lower total cost in high-concurrency, long-chain scenarios. Evaluation conclusions must therefore be tied to the business scenario.

    Public Chinese general-purpose evaluation results show the following trends for a new optimized version compared with the previous generation: overall accuracy rose slightly from about 71.0% to 71.5%; language and instruction following improved from 67.6% to 69.3%; reasoning and math improved from 73.6% to 74.8%; the tool-calling dimension moved from 64.2% to 64.5%, essentially flat. Average time per call was about 52 seconds, average tokens were about 2934, and cost per thousand calls was about RMB 60.8.

    The key takeaway from these numbers is that general evaluation frameworks cannot cover specialized capabilities such as tool-chain orchestration, scheduled tasks, and multi-agent collaboration. An overall score therefore reflects only the “baseline.” Enterprises focused on agent scenarios must build their own evaluation sets that closely mirror real workflows.

    4. Practical Advice for Building Custom Evaluation Sets

    1. Task layering: Sample across single-step tool calls, short chains within three steps, and long chains of ten or more steps, and measure success rates separately.
    2. Finer metrics: Beyond success rate, record average number of steps, retry counts, argument validation failure rate, and human takeover rate.
    3. Cost modeling: Total cost ≈ number of calls × (token consumption × unit price + resource usage from latency), which can then inform capacity planning.
    4. Regression mechanism: Run a fixed evaluation set after every model or prompt change to prevent capability regressions.

    5. Production Architecture and Cost Control

    A layered production architecture is recommended: an access layer for rate limiting and authentication; an orchestration layer for task decomposition and state machine management; a model layer with configurable capability tiers, where simple steps use a lightweight configuration and complex decisions use a higher-capability configuration; a tool layer that handles argument validation and auditing centrally; and an observability layer that tracks success rate, latency, and token curves through logging services and monitoring alerts. To elastically handle batches of long-chain tasks, container platforms and message queues can be combined to enable asynchronous processing and peak shaving.

    6. Conclusion

    The value of optimizing foundation models for agent workflows lies not in gaining a few tenths of a percentage point on general leaderboards, but in tool-call validity, long-chain stability, and cost per task. The right approach for developers is to first define the scenario and constraints, then build a layered evaluation set, use the four dimensions of accuracy, latency, tokens, and cost to drive model selection, and finally convert model capabilities into reliable system capabilities through validation, idempotency, and observability.