Layer-Level Control of Language Model Execution in Agent Frameworks

Ran Guan, Yiqi Lin, Xiangxi Tian, Yige Luo, Mi ZhouarXiv 2026

Imagine you’re driving a massive, fuel-hungry semi-truck across the country just to deliver a single envelope. It’s overkill, right? In the world of AI agents, we do this constantly. We send every prompt—no matter how simple—through the full depth of a massive Large Language Model (LLM), waiting for every single layer to process before we get an answer.

A new paper from Huawei’s 2012 Laboratories, titled "Layer-Level Control of Language Model Execution in Agent Frameworks," suggests we should start looking for the exit ramps.

TL;DR

Instead of treating LLMs as "black boxes" that you just feed prompts and wait for answers, this paper proposes a "harness" that lets an agent peek at the model's internal state mid-calculation. By doing this, the agent can decide to stop early, keep going, or "stitch" the calculation over to a much smaller, faster model, cutting latency by 15% without sacrificing accuracy.

What Problem Does This Paper Address?

Current agent frameworks (like LangChain or AutoGPT) treat LLMs as atomic units. You send a prompt, the "black box" whirrs, and a response pops out. The framework has zero visibility into what’s happening inside the model during those few hundred milliseconds of inference.

The problem is that not every task requires the full "brainpower" of a 70B or even an 8B parameter model. Sometimes, the model "knows" the answer by layer 20 of 36. Other times, the first 20 layers of a big model do the heavy lifting of understanding the context, but a tiny 0.6B model could easily finish the job. The authors want to move from "fixed-cost" inference to "pay-as-you-go" inference.

Methods

The authors introduce a design that adds two simple but powerful controls to the agent-model interface:

  1. observe(layer): This lets the agent see the "hidden state" (the mathematical representation of the data) after a specific layer.
  2. apply(action): This allows the agent to steer the execution.
Figure 1. Conventional agent frameworks interact with a language model through opaque prompt–response calls (left). Our design exposes intermediate states and execution controls at layer bound- aries, allowing the runtime to continue inference, exit early, or stitch into a smaller model; collected states support offline policy fitting and validation (right).

They tested three specific actions:

  • Continue: Business as usual. Go to the next layer.
  • Exit: Stop right here. Use the current internal state to make a final prediction immediately.
  • Stitch: This is the clever bit. They take the internal state of the big "source" model (Qwen3-8B) and use a small "bridge" (a simple neural network) to translate it into a format the small "target" model (Qwen3-0.6B) understands. The tiny model then finishes the task.

To make this work, they trained a Layer-wise Dispatcher. Think of it as a traffic cop sitting at layer boundaries, looking at the data and deciding: "Is this easy enough to exit now? Should we hand this off to the small model? Or do we need the big guns to keep firing?"

Datasets

  • Proxy Corpus: To train their "bridges" and "dispatchers," they built a dataset of 5,000 decision-making items (Yes/No, Multiple Choice) derived from WildChat, which consists of real-world user-assistant logs.
  • JevBench: For the final evaluation, they used a 231-item subset of JevBench v1.2, a benchmark specifically designed for AI decision models.

Key Insights and Ideas

  • The "Magic" Layer 23: The researchers found that before layer 23 (in their 36-layer model), the internal states are too messy to make a good prediction. Agreement with the final output is sparse. But after layer 23, the model starts to "crystallize" its answer, making it the perfect spot to start looking for exit ramps.
  • Stitching > Exiting: Simply stopping early (Exit) often hurts accuracy significantly. However, "Stitching" into a smaller model provides a "soft landing," preserving much more of the original model's reasoning while still saving time.
  • Least-Computation Supervision: They trained the dispatcher with a "lazy but smart" philosophy: always pick the cheapest action (Exit > Stitch > Continue) that still yields the same answer the full-sized model would have given.

Key Results

The prototype was tested on a MacBook Pro (M5 Max), and the numbers are quite promising:

  • Latency Win: They achieved a 14.9% reduction in mean latency (dropping from ~329ms to ~280ms).
  • Accuracy Parity: Surprisingly, the learned dispatcher actually scored slightly higher than the full model (71.86% vs 70.56%), likely because the dispatcher acts as a filter against some of the full model's "overthinking" or noise.
  • High Agreement: The system agreed with the full 8B model's predictions 91.34% of the time.
Figure 3. Mean end-to-end latency by starting layer on 231 JevBench items, averaged over five timings per item. The dashed line marks full Qwen3-8B latency.

Limitations and Future Work

While a 15% speedup is a great start, the authors are clear about the current boundaries:

  • Decision Tasks Only: This prototype only works for "typed decisions" (like picking A, B, or C). It doesn't yet handle open-ended text generation (like writing a poem), which is much harder to "exit" or "stitch" mid-sentence.
  • Frozen Policy: The current system was trained on a static dataset. In the future, they want the agent to learn and adapt its execution policy live as it interacts with users.
  • Hardware/Model Specifics: The results are currently tied to the Qwen model family and specific Apple silicon. How well this generalizes to other architectures remains an open question.

In short, the paper proves that we don't have to be passengers in the LLM's inference process. By cracking open the black box, we can make our agents faster, leaner, and a whole lot smarter about how they spend their "thinking" budget.

Summary updated

Abstract

Agent frameworks typically orchestrate language models through prompt-and-response interfaces. We propose a harness design that exposes intermediate model states and layer-level execution controls to the agent runtime. By connecting state collection, policy fitting, and execution, the design enables policies to allocate computation within and across models based on intermediate states. We demonstrate the approach with a prototype that learns stitching bridges and state-conditioned execution policies from paired model states, then applies them during inference to select among continue, exit, and stitch. For dispatcher supervision, we select the least-computation action whose full-vocabulary next-token prediction matches the source model's full-depth prediction, using continue when neither early action matches. We train these components on a frozen proxy corpus of 5,000 typed-decision items authored using source texts sampled from WildChat conversations, then evaluate the prototype on JevBench measuring task accuracy, agreement with full-model predictions, and end-to-end latency including runtime overhead. Preliminary results show an approximately 15% reduction in mean latency while maintaining task accuracy comparable to full-model inference.
BibTeX
@misc{guan2026layer,
  author = {Ran Guan and Yiqi Lin and Xiangxi Tian and Yige Luo and Mi Zhou},
  title = {{Layer-Level Control of Language Model Execution in Agent Frameworks}},
  year = {2026},
  eprint = {2611.29519},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.29519},
}
Figure