Why the Same LLM Performs Differently Across Agent Frameworks

    This article explains why the same model can deliver noticeably different results when moved between tools or agent frameworks. It breaks down the core constraints of large language models, then examines how prompts, context management, retrieval augmentation, tool definitions, agents, and the surrounding harness shape real-world output. It also outlines a practical troubleshooting and optimization sequence for diagnosing performance gaps and making model behavior more consistent.

    1. The Phenomenon: The Model Did Not Change, but the Experience Did

    Many developers have had a similar experience. In one chat interface, a model breaks down complex questions clearly and logically. Configure the same API key in an AI coding tool, and it often misses the point. Switch to another tool, and performance noticeably improves again. The API protocol has not changed, the model weights have not changed, and the parameter settings have not been touched. The only thing that changed is the entire scheduling and constraint mechanism surrounding the model.

    The industry often summarizes this relationship with a simple formula:

    1. Agent ≈ LLM + Harness

    The Harness can be understood as the “runtime framework” that wraps around the model and is responsible for assembling inputs, constraining outputs, scheduling tools, and managing state. Prompts, context, retrieval augmentation, and tool definitions are all just parts in its hands. In short: the model determines the upper limit of capability, while the runtime framework determines how much of that limit is actually delivered.

    2. The Engine: What a Large Model Actually Does

    At its core, a large model is a probability-based prediction program trained on massive amounts of text. Its only stable capability is this: given an input, predict the most likely next content token by token. The externally exposed form is usually a “text in, text out” interface, so plain that it carries almost no additional semantics.

    This design introduces three inherent constraints, and nearly all subsequent engineering concepts are patches for them:

    Inherent Constraint Plain Explanation Common Compensation
    Stateless Every call is an act of “amnesia”; without resubmitting history, it does not remember prior context Context management, session memory
    Knowledge cutoff It only knows information seen during training, not internal enterprise documents or real-time updates Retrieval augmentation, web search
    Text output only It cannot read local files, execute code, or call external systems Tool calling, agent orchestration

    Understanding these three points explains why the “same model” can vary dramatically across scenarios: the difference does not come from inside the model, but from how well the surrounding structure compensates for these three weaknesses.

    3. Peeling Back the Layers: The Real Division of Labor Across Six Concepts

    1. Prompts: Stating the Task Constraints Clearly

    A prompt is not a “magic spell,” but an explicit declaration of the task goal, input format, output format, and boundary conditions. A more reliable engineering practice is structured organization: role and goal, available information, constraints and prohibitions, and output template. The more explicit the constraints, the smaller the variance in model output.

    1. Goal: Classify the user question into one of three categories: billing / permissions / incident
    2. Input: The user's original description
    3. Constraints: Output JSON only, with fields label and confidence
    4. Prohibited: Do not output explanatory text

    2. Context: The Model’s “Temporary Working Memory”

    Context is all the content actually sent to the model in a given call. It typically includes system instructions, conversation history, retrieved snippets, tool return results, and the current question. It is limited by the context window, so the core engineering question is not “how much to stuff in,” but “what to include within a limited budget.” Common strategies include sorting by relevance, sliding-window truncation, history summarization, and placing key conclusions at the top.

    3. Retrieval Augmentation: Fetching External Knowledge on Demand

    The idea behind retrieval augmentation is to retrieve first, then assemble: split documents into chunks and build an index, recall the most relevant chunks when a user asks a question, and feed them to the model as part of the context. It addresses knowledge timeliness and private data problems. Practical priorities include chunking granularity, recall quality, reranking, and citation traceability; without traceability, answers cannot be verified.

    4. Tools: Turning the Model from “Able to Talk” to “Able to Act”

    Tool calling abstracts external capabilities into structured descriptions the model can read: name, purpose, parameter schema, and return format. The model outputs a structured call intent, the surrounding framework executes it, and the result is fed back into the context, forming a closed loop. If tool descriptions are vague, the model will pick the wrong tool or pass the wrong parameters, which is a frequent source of experience differences.

    5. Agents: Organizing Single-Step Calls into a Workflow

    An agent adds a layer of control logic on top of the model: planning steps, selecting tools, checking results, retrying on failure, and deciding when to stop. It does not raise the model’s intelligence; it turns one-off text generation into iterative task execution.

    6. The Runtime Framework: The Real Dividing Line for Experience

    The runtime framework is responsible for the unified orchestration of the above five layers: prompt templates, context budgets, retrieval pipelines, tool registration and permissions, logging and tracing, and failure fallbacks. When two pipelines use the same model but perform very differently, the cause can usually be traced to four differences: context organization strategy, tool description quality, error recovery mechanisms, and output validation strength.

    4. A Practical Troubleshooting and Optimization Sequence

    1. Fix the variables first: same model, same temperature, same input, and only swap the surrounding structure for comparison.
    2. Check the context: confirm whether history has been truncated and whether key constraints have been pushed out of the budget.
    3. Check tool descriptions: whether required parameters are clearly defined and whether the return structure is stable.
    4. Check retrieval quality: whether recalled chunks are truly relevant and whether they include sources.
    5. Check validation and retries: whether structured output is parsed and validated with a limited number of retries.
    6. Build observability: use logging services and monitoring alerts to record each call’s input summary, tool latency, and failure reasons, so optimization has a basis.

    5. Conclusion

    The model is the engine; the runtime framework is the transmission and chassis. To reliably deliver the same model capability, the focus is not on swapping models, but on turning context budgets, retrieval quality, tool contracts, process control, and observability into measurable, reusable engineering assets. In related engineering practice, Baidu AI Cloud typically also builds capabilities around these common areas rather than relying on a single model itself.