Built-In Tools vs Custom Tools in LLM Agents
In an AI agent, a tool is anything the model can ask to use, like a search engine, a database lookup or…
No. The text you type into a chat box is only one part of what a large language model (LLM) receives. The full request can also contain system and developer instructions, earlier messages, tool definitions and retrieved documents.
The visible prompt is the text a person sees or types. The effective input is everything the model receives after the application and the provider have assembled and processed the request. The output is the response the model generates from that input. Identical visible prompts do not prove that the effective inputs were identical. Even identical effective inputs can produce different outputs.
"Same prompt" can mean five different things:
The first level is the weakest. The fourth is the most direct definition of identical model input. You need the fifth only when you want to reproduce an output.
When an answer changes but the text box shows the same words, that is weak evidence that nothing else changed. The application may have added a different policy, retrieved different records, sent a different tool schema or included a different conversation history.
A benchmark that stores only the user's wording cannot fully reproduce a chat, retrieval or agent request. To rerun it, you need versioned copies of the complete context and the execution environment.
A security review has to look past the text box as well. Invisible Unicode characters, pasted document text, retrieved web pages and tool results can influence a model without looking like ordinary user instructions. OWASP's prompt-injection guidance covers both inputs that people cannot see and instructions that arrive through external content.
In all three cases, compare the final request after formatting and preprocessing before you conclude that the model behaved differently.
A production LLM request often follows this path:
Visible text
-> API request
-> Context assembly
-> Chat serialization
-> Tokenization or multimodal preprocessing
-> Model computation
-> Decoding
-> Visible output
The model never sees the text box. It works on tokens, which are pieces of text such as words, parts of words, punctuation or whitespace. Each token has an integer ID. Images and audio are turned into arrays of numbers called tensors.
Suppose a user types:
Summarize this incident report.
The model may receive that sentence together with system instructions, earlier messages, role markers and the incident report itself. The model and the provider decide the exact representation.
The visible message first goes to application code. That code, and in some cases the provider, assembles the request from the latest user message and other state. Chat APIs usually represent the request as an ordered list of messages instead of one plain string. Each message has a role, such as system, user or assistant.
The same words can have a different effect in a different role. A sentence sent as a system instruction does not sit in the same position as the same sentence sent by the user or quoted inside a document.
Next, the messages are serialized into the format a particular model expects. A chat template is the model-specific rule that does this. Depending on the model, it adds role markers, delimiters at the start and end of messages, special control tokens, whitespace and a marker where the assistant should start generating. The text that comes out of the template is the rendered request. A tokenizer then converts it into token IDs.
Hugging Face's chat-template documentation shows why the message content alone is not enough. In its examples, Mistral's instruct model wraps each user message in [INST] and [/INST], while other models use explicit system, user and assistant markers. These examples come from open models, and hosted providers do not all use one shared format either.
A template, tokenizer or preprocessing upgrade can therefore change the token IDs even when the API message objects stay the same. For reproducible inference with open models, record the template identifier, the tokenizer revision, the rendered text and the token IDs when you can.
On a self-hosted model, you can often inspect the final token IDs directly. With a hosted API, the request body you send may not show the provider's full serialization. Some providers also add instructions or processing for specific features that you cannot always inspect. Rely on what the provider documents, such as the tool-use system prompt described below, and do not guess at undisclosed prompts.
An identical API request is stronger evidence than identical text in a chat window, but it does not show every change on the provider's side. Before you call two hosted requests equivalent, check the provider's documented defaults for any settings you did not send.
Two strings can look identical and still be different input. Unicode, the standard used to encode text characters, allows several sequences that display the same way. The letter é, for example, is either one precomposed character or a plain e followed by a combining accent. The Unicode normalization report describes how these sequences relate.
Other differences that are hard to spot include:
These differences change the bytes, and they can change the token IDs. In a reproducibility or security investigation, inspect code points and encoded bytes before you compare strings. A deliberate normalization policy helps, but do not apply compatibility normalization (NFKC or NFKD) blindly to technical identifiers, math notation or other text where the differences carry meaning.
Keep the original input bytes, record the normalization policy you chose, and store the normalized text separately. If you cannot keep sensitive content, store hashes of both versions.
Besides the latest user message, application code may add:
For example, the visible message "Summarize the report" gives a different effective input when the conversation contains a financial report than when it contains an incident report.
An attached image may be resized, converted to another format or cropped before the model receives it. An attached document may be extracted into text, split into sections or filtered before it is included. If these inputs affect a production decision, record attachment hashes and preprocessing settings.
Unless your application stores all of this with each call, the visible user text is not a complete record of the request.
When tools are enabled, each tool definition can include a name, a description, a parameter schema, permission settings and expectations about the output. Later turns also carry the tool calls the model made and the results that came back.
Anthropic's tool-use documentation states that tool names, descriptions and schemas count as input tokens. It also documents a special system prompt that the API adds when tools are enabled. Google's Gemini tool documentation describes a similar flow in which function declarations go out with the request and the function results return to the model as later context.
A response schema or other format constraint for structured output tells the provider what shape the answer must take. If you change the schema, you change the effective request or its settings, even when the user's wording stays the same.
For an agent, a matching last user message says little on its own. The tool definitions and schemas have to match as well, and so do the tool-choice settings, earlier tool calls and tool results.
Retrieval-augmented generation (RAG) selects passages from an external collection of documents and adds them to the context sent to the model. The original RAG research describes generation conditioned on passages retrieved from an external knowledge source.
The same question then produces a different context when any of these change:
Retrieved content also opens a path for indirect prompt injection. A document or web page can contain instructions that the model reads as part of its context. Pinning the corpus version, document hashes, chunk IDs and result order makes retrieval comparisons meaningful and helps security reviewers trace where an unexpected instruction came from.
A single prompt string is a reasonable approximation for a plain completion API that sends one fixed text directly to a fixed model. Even there, strict reproducibility needs stable byte encoding, preprocessing, tokenizer files, model weights and inference settings.
The approximation breaks down for chat, multimodal, retrieval and agent systems. There, matching strings only show that one visible or intermediate text field matches. They do not show that the full request, the token sequence or the execution environment matched.
The model computes a probability distribution over possible next tokens, and a decoding policy picks tokens from that distribution. Temperature, top-p, top-k, the random seed, the maximum output length, stop rules and tool-choice settings all affect that choice. With sampling, the same input can produce different continuations.
Even with fixed sampling settings, the serving infrastructure can add variation. Microsoft's Azure OpenAI reproducibility documentation calls seed-based reproduction best effort and says that identical settings do not guarantee identical results.
The model behind a name can change too, because a provider may update the weights, tokenizer, serving stack or routing behind a stable alias. Where the provider offers a fixed snapshot or revision, pinning it reduces this drift. OpenAI's model documentation describes snapshots as a way to lock a specific model version. A snapshot alone does not guarantee identical output.
Prompt caching normally leaves the logical prompt unchanged. It reuses computation for a common prefix, as described in OpenAI's caching announcement.
A changed answer does not prove that the input changed. An identical answer does not prove that the input stayed the same either. Record the output settings too, even though they are not part of the token input.
If the effective requests of two calls match, compare the decoding settings, model revision, backend metadata and serving behavior next.
Treat the effective input as a versioned build artifact. For each important call, keep a manifest with enough detail to rebuild how the context was assembled and to compare two calls.
Visible prompt
Conversation and added context
Serialization and preprocessing
Execution
Sensitive prompts and documents can stay in a protected store while hashes, versions, order and metadata support the comparison. The NIST AI Risk Management Framework also calls for documenting an AI system's context, measuring its performance under conditions similar to deployment and monitoring it in production.
Keep input stability apart from answer quality and output determinism. A regression test should first establish whether the request changed. Only then does it make sense to ask whether the model or the decoder responded differently to the same request.
Serialization tests start from a fixed message object. After a change to the SDK, middleware, chat template, tokenizer or tool schemas, they compare the rendered request and the token IDs with the previous result. The test fails when an unexpected difference appears.
Augmentation tests start from a fixed visible prompt. They check that the expected policies, conversation state, retrieved chunks, tool results and attachments are present and in the right order. Pin the retrieval inputs when the result has to stay reproducible.
Behavioral tests run equivalent paraphrases, formatting variants, different example orders, whitespace changes and Unicode variants of a prompt. They measure how sensitive the model is to these changes, in addition to average task accuracy.
For classification tasks, Errica and colleagues define two measures that fit these tests. Sensitivity measures how predictions change across rephrasings of the prompt, and it does not need ground-truth labels. Consistency measures how predictions vary across rephrasings for inputs of the same class.
Sclar and colleagues measured differences of up to 76 accuracy points between plausible few-shot prompt formats when they evaluated LLaMA-2-13B. A 2024 preprint found that GPT-3.5-turbo's performance on a code translation task varied by up to 40% depending on whether the prompt template used plain text, Markdown, JSON or YAML. Xiang and colleagues found that results depend strongly on the order of in-context examples. These figures come from specific studies and setups. They do not predict what will happen in your production system.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com