LLM Evolution in the Agentic AI Era: Efficiency and Long Context

    This article explains why long-horizon agentic tasks are difficult, breaks down token efficiency into training, inference, and agent-level efficiency, and reviews long-context techniques for positional encoding, compute and memory, and information utilization. It also discusses the scope and limits of Scaling Laws, provides a troubleshooting checklist for multi-step agent failures, and offers practical selection guidance based on task characteristics.

    1. What Makes Long-Horizon Tasks Hard

    In the traditional question-answering mode, an LLM receives a question, outputs an answer, and the task ends. Agentic models need to understand a user’s high-level goal, break it into subtasks, call tools such as search, code execution, or internal interfaces, and adjust the next action based on the result returned at each step.

    The difficulty of this mode lies in the number of steps. A task may contain dozens of tool calls, and the return content of each call is appended to the context. As the number of steps increases, the context keeps growing. The model needs to retain memory of the initial goal across a long sequence while avoiding interference from intermediate noise. Therefore, the success of long-horizon tasks mainly depends on three things: whether the goal can be maintained stably, whether the context can be used effectively, and whether the reliability of a single inference step remains acceptable after accumulating across multiple steps.

    2. First, Clarify What Token Efficiency Means

    “Token efficiency” points to different things in different contexts, so it must be distinguished before discussion. This article divides it into three levels.

    • Training efficiency: the capability improvement brought by each training token. A common metric is the number of training tokens required to reach the same evaluation score. A smaller value indicates more sufficient sample utilization.
    • Inference efficiency: the number of tokens consumed and the latency required to complete a task. Common metrics include average tokens per successful task, time to first token, and cost per million tokens.
    • Agent efficiency: in multi-step tasks, the proportion of effective information in the full context. Verbose logs returned by tools and repeated historical dialogue both reduce this proportion.

    On the training side, common efficiency-improvement methods fall into the following categories.

    Data mixing and curriculum learning. Through deduplication, quality filtering, and dynamically adjusting the proportions of data from different sources, the model can learn more useful patterns under the same compute budget. The benefit of such methods depends on data quality. When the data scale is already large, the benefit is usually marginal and diminishing.

    Sparse activation architectures. Mixture-of-Experts (MoE) models are a typical example. Mixtral 8x7B has about 46.7B total parameters, but only about 12.9B parameters are activated per token. In this way, the total capacity of the model can increase without a proportional increase in computation per inference. The cost is that the routing mechanism adds engineering complexity, and memory usage is still determined by the parameters of all experts.

    Post-training reinforcement learning. RLHF (reinforcement learning from human feedback, represented by InstructGPT) is mainly used to make model outputs conform to human preferences. Its core benefit is alignment, which is not directly equivalent to improved reasoning capability. On tasks such as math and code where answers can be automatically verified, reinforcement learning based on verifiable rewards is better suited to improving reasoning sample efficiency. Such benefits depend on the base model and evaluation set and need to be validated on an independent test set, not just by looking at training curves.

    3. Long Context: After the Window Grows Longer, Can the Model Use It Well?

    Work on extending the context window can be divided into three parts: positional encoding, compute and memory, and information utilization.

    Positional encoding. Mainstream models currently generally use Rotary Position Embedding (RoPE). When the inference length exceeds the training length, the attention pattern deviates from the distribution seen during training, and perplexity rises accordingly. Common extrapolation methods include the following.

    • Position Interpolation (proposed by Meta in 2023): compress position indices proportionally into the training range. It usually requires a small amount of long-text fine-tuning to be stable.
    • NTK-aware interpolation: adjust the base frequency of RoPE so that high-frequency and low-frequency components are scaled to different degrees. It can maintain usable performance within a certain length without fine-tuning, but it still degrades noticeably beyond a certain multiple.
    • YaRN (proposed in 2023): further distinguishes different frequency dimensions based on the NTK-aware idea and adjusts the attention temperature, showing more stable performance at longer lengths.

    The applicable boundaries of these methods are all related to the ratio between the training length and the target length. In practice, after exceeding the training length by 2 to 4 times, most schemes require continued training with long-text data. Specific values should be measured on the target task and should not be directly copied from conclusions in papers.

    Compute and memory. The computation of standard self-attention grows quadratically with sequence length. FlashAttention (2022) reduces reads and writes to high-bandwidth memory through tiled computation, improving speed and reducing memory usage without changing the results. During inference, the memory usage of the KV cache can be estimated with the following formula:

    KV cache bytes ≈ 2 × number of layers × number of KV heads × head dimension × sequence length × bytes per element

    Each time the sequence length doubles, the KV cache also doubles. PagedAttention (vLLM project, 2023) manages the KV cache in blocks, reducing memory fragmentation and allowing the same GPU to serve more requests simultaneously.

    Information utilization. Even if the window is long enough, the model may not be able to use information in the middle well. Research by Liu et al. (2023) found that when key information is located in the middle of a long document, the model’s question-answering accuracy drops noticeably, and accuracy shows a U-shaped curve with position. Response methods include: placing key instructions at the beginning or end of the prompt; first using retrieval to filter relevant snippets, then reranking by relevance; training with data containing long-distance dependencies; and summarizing and compressing the agent’s history trajectory instead of retaining all tool returns verbatim.

    4. The Role and Boundaries of Scaling Laws

    Scaling Laws are an important empirical basis for LLM development. Research by Kaplan et al. (2020) showed that within a certain range, the test loss of a model has a power-law relationship with parameter count, data volume, and compute. In a log-log coordinate system, this relationship appears as an approximately straight line, but it is not linear in the original coordinates.

    The Chinchilla study proposed by Hoffmann et al. (2022) further pointed out that under a fixed compute budget, parameter count and training token count should grow roughly proportionally. Its empirical conclusion is that each parameter corresponds to about 20 training tokens. This conclusion indicates that many early models suffered from insufficient training data.

    Regarding architecture comparisons, the study by Kaplan et al. showed that in their experimental setting, the test loss of Transformer was lower than that of LSTM, and as model scale increased, the gap between the two remained stable. This result comes from a specific dataset and training recipe and cannot be directly generalized as a conclusion for all tasks. In addition, LSTM benefits less from longer contexts, which is consistent with Transformer’s ability to exploit long-range dependencies.

    When using Scaling Laws, three points should be noted. First, a decrease in loss does not mean that downstream task capability grows linearly; the relationship between the two depends on the task and evaluation method. Second, the scale of high-quality public text is limited, and data exhaustion will change the shape of the curve. Third, when comparing different models, the same evaluation protocol and data split must be used.

    5. Troubleshooting Checklist for Long-Horizon Agent Tasks

    When an agent fails in a multi-step task, check in the following order.

    1. Goal drift: check whether the task goal is repeated in each round of the prompt. If it appears only in the first round, subsequent steps are likely to deviate.
    2. Context bloat: check the length of tool returns. Set truncation thresholds for excessively long logs and retain summaries and key fields.
    3. Repeated calls: check whether the same tool is called multiple times consecutively with the same parameters. Failure states should be recorded, and a maximum retry count should be set.
    4. Loss of key information: check whether key conclusions obtained earlier are still in the context. They can be written to external memory or placed in a prominent position in the prompt.
    5. False completion: check whether the task has verifiable completion conditions, such as tests passing, a file existing, or a value matching. Without verification conditions, the model is prone to declaring completion early.

    6. How to Choose

    Selection can start from task characteristics.

    If the task has few steps and a clear structure, prioritize optimizing prompts and tool descriptions. This is usually more effective than changing the model or extending the window.

    If the task needs to process long documents, first measure the evaluation score at the target length, then decide on the positional encoding scheme. Do not look only at the nominal window size.

    If cost is sensitive, focus on the number of tokens per successful task rather than the price of a single call. For an agent that repeatedly calls tools, no matter how low the per-call price is, the total cost may still be high.

    The advancement of Agentic AI requires the joint efforts of training methods, architectures, inference systems, and task design. Every technology has clear applicable conditions, and only after its effect has been measured on a concrete task can a selection conclusion be reliable.