LLM Selection Guide: Context Windows, Output Budgets, and Agent Practices

    This guide explains how to choose large language models based on constraint matching rather than spec-sheet comparison. It breaks down context window capacity, single-request output budgets, and input modality limits, then outlines a layered selection strategy for agents, along with cost and capacity planning. Readers will learn how to treat output limits as dynamic constraints, normalize vendor units, and keep fallback paths in their architecture.

    1. The Real Problem: Match Constraints, Don’t Compare Specs

    In practice, developers often pull up spec sheets for various LLMs and try to make a quick decision based on a single dimension such as context length or output length. The flaw in this approach is that the numbers on a spec sheet are upper bounds measured under ideal conditions by the vendor, while real workloads are the result of multiple constraints stacked together. A rigorous selection process should first define the hard constraints the business places on input shape, context capacity, per-request output budget, and chain length, and then match candidates against them, not the other way around.

    One common confusion needs clearing up first: the shorthand name a user says out loud often does not match the identifier used in the official API. Engineering work must rely on the invocation identifier given in the official documentation and maintain it centrally in configuration management, rather than hard-coding colloquial names into the code.

    2. Technical Breakdown of Three Core Dimensions

    2.1 Context Window: Nominal Capacity vs. Usable Capacity

    The four mainstream general-purpose models all document context sizes in the million-token range, but engineering work must separate three concepts:

    • Nominal context: the maximum number of tokens the documentation says can be held;
    • Maximum input: the number of tokens a single request can carry after the reserved output space is deducted;
    • Effective context: the range at which the model’s recall accuracy for mid-document information starts to drop noticeably in long-text scenarios.

    Vendors are not consistent in how they write units: some use K, some use M, and some give an exact integer (for example, 1,048,576). Never treat different unit conventions as exactly equal. When comparing across vendors, convert to a common unit and leave a safety margin. In practice, plan your workload at 70%–80% of the nominal value and keep the remainder as buffer.

    2.2 Per-Request Output Budget: The Real Bottleneck in Agent Scenarios

    Differences in output budget are often more critical than context. For some models, the output length allowed in non-thinking mode differs from that in thinking mode, and thinking mode usually permits longer output; some models have a low output ceiling, while others support a single output on the order of hundreds of thousands of tokens; still others adopt a strategy of “default output length plus dynamic constraint from the remaining context.”

    This means: the output limit is not a fixed value but a dynamic quantity coupled with input length. The implementation must validate the budget before sending a request:

    1. def check_budget(input_tokens, want_output, ctx_limit, out_limit, reserve_ratio=0.2):
    2. usable = int(ctx_limit * (1 - reserve_ratio))
    3. if input_tokens + want_output > usable:
    4. raise ValueError("Exceeds usable context; compress the input or lower the output budget")
    5. return min(want_output, out_limit, usable - input_tokens)

    2.3 Input Modality Boundaries

    Candidate models differ in what they accept as input: some support three types, text, image, and video; others support only text and image. If the workload involves video understanding, the options narrow significantly, and the architecture should reserve a fallback path, such as extracting key frames and converting them into an image sequence, to avoid the whole solution failing because a modality is unsupported.

    3. A Layered Selection Strategy for Agent Scenarios

    The defining traits of an agent are long chains, multi-turn tool calls, and accumulating state, so message history keeps growing. It is worth splitting models by task layer:

    1. Planning layer: needs the strongest reasoning and the longest output budget, used to produce complete plans and code;
    2. Execution layer: high-frequency tool calls, emphasizing low latency and stable structured output;
    3. Verification layer: a small model handles format checks, field extraction, and initial risk screening.

    Pairing this with context compression (summarizing history, retrieval-based recall, sliding windows) and result caching can significantly reduce total cost. An illustrative strategy:

    1. if task_type == long_document_generation: pick large output budget + long context
    2. elif task_type == multimodal_understanding: pick a model that supports the target modality
    3. else: pick a low-latency execution-layer model + cache

    4. Cost and Capacity Planning

    Cost cannot be judged by unit price alone; model it as: cost per task = (input tokens × input price + output tokens × output price) × retry factor. In agent scenarios the retry factor is often above 1.2, and in long-context scenarios the input side’s share rises quickly. Build an observability system that continuously collects token consumption, timeout rate, and failed-retry rate through logging services and monitoring alerts, and iterate the budget weekly.

    5. Conclusion

    Selection is not about finding the “strongest model” but the “best-matching combination of constraints.” Rely on the invocation identifier in the official documentation, normalize unit conventions, distinguish nominal from effective capacity, treat the output budget as a dynamic constraint, and preserve layered multi-model routing and fallback capability in the architecture. Only then can you achieve a stable balance among cost, latency, and quality. If an organization wants to deploy this on Baidu AI Cloud, it can build a unified model gateway on top of general-purpose model services, a container platform, and monitoring and alerting capabilities to enable multi-model routing and quota governance.