Rethinking LLM Selection: Evaluate Models and Engineering Frameworks Together

    This article explains why LLM selection should evaluate the model and its surrounding engineering framework together. It covers task complexity tiers, cost structure, orchestrator-executor multi-agent design, context management, evaluation methods, and a production checklist.

    1. From Single-Model Scores to System-Level Results

    When choosing a large language model, many teams look at public leaderboard scores first. Leaderboard results are a useful reference, but they measure performance in a specific test environment. The same model can show very different task completion rates in different runtime environments. The model handles understanding and generation, while tool calling, context organization, retry strategies, file reading methods, and permission boundaries are determined by the surrounding engineering.

    For this reason, teams should evaluate the model and the runtime framework as one system. The evaluation usually covers four areas:

    • The model’s own reasoning and comprehension abilities
    • The accuracy of tool calls, and whether parameter formats stay stable
    • The ability to retain early information in long sessions
    • The task decomposition, failure retry, and state logging provided by the runtime framework

    Evaluating only the model and ignoring the framework can lead to conclusions that do not match production results. Likewise, evaluating only the framework and ignoring the model makes it impossible to tell which layer is causing a problem.

    2. Three Dimensions of Model Selection

    2.1 Task Complexity

    Task complexity sets the minimum capability a model needs. Common tasks fall into three categories:

    1. Simple tasks: text classification, summarization, and field extraction. These tasks have clear rules. A lightweight model is usually sufficient, with low latency and low cost.
    2. Moderately complex tasks: tasks that require multi-step reasoning, or that combine multiple files and tool results to reach a judgment. These tasks suit more capable models and should include a validation step.
    3. Long-running tasks: projects that take hours or even several days to complete. The main difficulties are context management and resuming work from checkpoints. The model’s single-inference ability accounts for only part of the outcome.

    Selecting models by complexity tier avoids sending every request to the highest-tier model.

    2.2 Cost Structure

    LLM pricing usually includes several components: input tokens, output tokens, and cache-hit input tokens. The cost of a single task can be estimated with the following formula:

    1. Single-task cost = regular input tokens × regular input price
    2. + cache-hit tokens × cached input price
    3. + output tokens × output price

    In most pricing plans, output tokens cost more than input tokens, and cache-hit input tokens cost much less than regular input tokens. Two optimizations are therefore the most effective: reducing unnecessary output, and making repeated prefix content hit the cache as often as possible. For example, fixed system instructions, project descriptions, and tool definitions should be placed at the beginning of a request to improve the cache hit rate.

    2.3 Context and Multimodal Inputs

    Long-context capability lets a model process a large amount of material in one pass. However, the more material there is, the more noise it contains. Text, images, audio, video, and documents each require different preprocessing. A practical approach is to perform structured extraction first, such as converting a document into a list of sections or a table into key-value pairs. Then, only the fragments relevant to the current subtask are placed in the context. This reduces cost and lowers the chance that the model is distracted by irrelevant information.

    3. Orchestrator-Executor Collaboration

    In multi-agent collaboration, a common structure is the orchestrator-executor pattern. The orchestrator understands the overall goal, splits it into subtasks, and aggregates the results. Executors handle subtasks with clearly defined boundaries. The orchestrator typically uses a more capable model, while executors can use lower-cost models.

    This division of labor has three direct benefits:

    • Subtasks can run in parallel, which reduces overall completion time.
    • The orchestrator only handles summaries and conclusions, which cuts the cost of repeatedly reading source material.
    • When one subtask fails, only that subtask needs to be rerun, not the entire workflow.

    The following simplified sketch shows the basic skeleton of parallel scheduling:

    1. from concurrent.futures import ThreadPoolExecutor
    2. def call_model(model_name: str, prompt: str) -> str:
    3. """Call a general-purpose model interface and return the text result. The concrete implementation depends on the service being used."""
    4. raise NotImplementedError
    5. def run_subtask(subtask: dict) -> dict:
    6. result = call_model("lightweight_model", subtask["prompt"])
    7. return {"id": subtask["id"], "output": result}
    8. def orchestrate(goal: str, subtasks: list[dict], max_workers: int = 4) -> str:
    9. with ThreadPoolExecutor(max_workers=max_workers) as pool:
    10. results = list(pool.map(run_subtask, subtasks))
    11. summary_prompt = f"Goal: {goal}\nSubtask results: {results}\nSummarize and point out any conflicts."
    12. return call_model("reasoning_model", summary_prompt)

    In real engineering work, pay attention to the following points:

    • Each subtask needs a clear input and output format so the orchestrator can validate it.
    • The degree of parallelism should respect the service’s rate limits. When the limit is exceeded, requests need to be queued or retried with backoff.
    • The orchestrator should check the executors’ results for consistency rather than accepting them without review.

    4. Context Management and Repeated Reads

    In long sessions, the context window fills up with conversation history and repeatedly read file contents. The three methods below help control this problem.

    4.1 File Summary Caching

    The same file may be read several times within one task. You can compute a content hash for each file and store its summary. If the file content has not changed, reuse the stored summary. Regenerate the summary only when the content changes.

    1. import hashlib
    2. _summary_cache: dict[str, str] = {}
    3. def get_file_summary(path: str, content: str, summarize) -> str:
    4. digest = hashlib.sha256(content.encode("utf-8")).hexdigest()
    5. if digest not in _summary_cache:
    6. _summary_cache[digest] = summarize(content)
    7. return _summary_cache[digest]

    4.2 Session State Compression

    Conversation history does not need to be kept in its original form. You can periodically compress it into structured state. This state includes the current goal, completed items, pending items, key constraints, and decisions already made. For each new request, carry only the compressed state and the most recent few turns of conversation.

    4.3 On-Demand Retrieval

    Instead of placing an entire document in the context, retrieve the passages relevant to the current subtask first. Retrieval can be keyword-based or based on vector similarity. Set an upper limit on the number of retrieved results so that low-relevance content does not fill the context.

    5. Evaluation Design

    Effective evaluation meets three conditions: the task set matches real business work, the compared items are consistent, and the metrics cover both quality and cost. The recommended steps are as follows:

    1. Extract representative tasks from production logs, covering each complexity tier, and build a fixed evaluation set.
    2. Evaluate two cases separately: direct model calls and model calls within the runtime framework.
    3. Record the result of each task and report statistics grouped by task type.
    4. Calculate cost and latency together to determine whether the performance gain justifies the additional investment.
    Metric Meaning Focus
    Task success rate Share of results that pass the acceptance criteria Report separately for each task type
    Average latency Time from request to completion Effect of parallelization
    Cost per task Estimated fee based on the billing formula Cache hits and output length
    Manual edit count Number of corrections a person must make Practical usability of results

    Looking only at overall scores can hide problems. A model may perform well on simple tasks but make frequent errors on long-running tasks. Grouped statistics reveal these differences.

    6. Production Readiness Checklist

    Before deploying the solution to production, confirm each of the following:

    • Every task type has clear acceptance criteria.
    • Tool call parameters are checked for type and range.
    • Agents have a maximum step count and a per-step timeout to prevent infinite loops.
    • Sensitive operations such as deleting, sending, or deploying require manual confirmation.
    • Logs record model inputs and outputs, with personal information and secrets redacted.
    • After every model change or runtime framework adjustment, run regression tests with the fixed evaluation set.

    7. Summary

    The model’s capability is the foundation, but the runtime framework determines whether that capability can reliably produce business results. When selecting a solution, evaluate the model, the framework, and the cost together, and design layered systems based on real tasks. By building an evaluation system along these lines, teams can find a better balance among quality, speed, and cost.