How Do AI Models, Knowledge, Memory, and Tools Work Together?

See how an AI assistant’s model, trained knowledge, context window, memory, retrieval and tools fit together as one system, and where each part can fail.

When you ask an AI assistant a question, it can feel like you are talking to one thing. You are actually using a system of parts, and each guide in this chapter has opened up one of them. AI Fundamentals maps the broader set of building blocks; this chapter-closing guide narrows the view to how the parts coordinate when an assistant produces one answer.

The short version: in the simple architecture mapped here, the model generates the language in the answer, while the surrounding system supplies context, runs tools, and may format or filter the result. The model generates a response from whatever text sits in its context window, and most of the rest of the system decides what goes into that window or acts on what the model asks for. Knowledge reaches the model two ways: as patterns stored in its parameters during training, and as information supplied when you ask. Memory is usually information an application saved outside the model and uses to shape a later response. Retrieval finds relevant documents; tools let the model ask other software to search, calculate or act. The application layer around it all sets the instructions, rules and permissions.

TL;DR

  • The model generates; the system supplies. A model writes from the text in its context window, which can include instructions, conversation, documents and tool results [1].
  • Knowledge has two sources. Patterns learned in parameters during training, and information placed in the context at answer time [1, 2].
  • Saved memory is separate from retraining. In the products described here, applications store selected information outside the model and use it to shape later responses [3, 4].
  • The model requests tools; other software runs them. Depending on the design, the developer’s application or the provider’s servers carry out the request [5, 6].
  • Rules come from the application layer. System instructions guide the model without guaranteeing compliance, so permissions are enforced outside it [7, 8].

The System on One Page

Read the table top to bottom, roughly in the order each part touches a request.

ComponentWhat it contributesWhere it can go wrong
Application layerSystem instructions, rules, permissions and the choice of connected tools and data [7]Instructions are not guaranteed to be followed; loose access rules expose data [9, 7]
ModelGenerates the response from the context it receivesFluent text that is unsupported or wrong
Knowledge in parametersBroad patterns and facts absorbed during training [2]Can become outdated; hard to trace or revise [10, 2]
Context windowThe working text for this response: instructions, conversation, files, tool results [1]Overloaded context lowers accuracy and recall [1]
Conversation contextIn common chat APIs, earlier turns sent again with each new message [1]Older turns may be trimmed, summarized or compacted [1]
Saved memoryUser details stored outside the model and reinserted when relevant [4]Stale or sensitive details resurface; deleting a chat may not delete them [4]
RetrievalA few relevant passages from documents or databases [9]Misses the right passage or ignores access rules [9]
ToolsSearch, code, browsing and app actions run by other software [5, 11]Wrong inputs, bad results or hidden instructions in returned content [12]
The answerText, citations or a proposed action for a person to useSounds authoritative even when an earlier row failed

Two Kinds of Knowledge

The first kind is knowledge learned in parameters, the adjustable numbers inside a model that are tuned during training. The researchers who proposed RAG in 2020 likened a pretrained model to an implicit knowledge base held in those numbers, one that is hard to expand or revise [2]. That snapshot is fixed when training ends, and everyday use does not update it; the training vs. inference guide explains why.

The second is knowledge supplied at answer time: a file you upload, a retrieved passage, a search result or a saved memory. It sits in the context window for the current response only, and it can be newer than the training data or specific to you. Google says connecting Gemini to Google Search lets it cite verifiable sources beyond its knowledge cutoff, the point where its training data stops [10]. Anthropic describes its web search tool in similar terms [5].

This matters when you judge an answer. A claim about a recent event, a current price or your employer’s policy is only as good as the information supplied for that request.

The Context Window Is Where Everything Meets

Every row in the table either fills the context window or acts on what the model writes from it. Anthropic defines the context window as all the text a model can refer to while generating a response, including the response itself, and contrasts it with the model’s training corpus [1]. On Anthropic’s API, system instructions, every message (tool results and documents included) and the descriptions of available tools all count toward the limit [1].

Space is not the only constraint. Anthropic reports that accuracy and recall degrade as the amount of text grows, and its engineers call context a finite resource with diminishing returns [1, 3]. So much of the system’s work is selection: deciding which instructions, history, memories, passages and tool results earn a place. How Much Can AI Read or Remember at Once? covers what fills the window and what happens when it overflows.

Two Kinds of Memory

In AI products, “memory” usually means one of two quite different things.

In-conversation context is the chat itself. In common chat APIs, including Anthropic’s, the application sends earlier turns with each new message, which lets the model continue the conversation [1]. When an application trims, summarizes or compacts older context, an early instruction may lose influence [1].

Saved memory is information an application stores outside the model and brings back in later conversations. As of November 2026, three providers describe versions of it [13, 4, 14]:

  • OpenAI says ChatGPT keeps saved memories separately from chat history, so deleting a chat does not automatically delete a memory created from it, and temporary chats do not create memories [4].
  • Google lets Gemini Apps users save details about their life, work or preferences, or ask Gemini to consult past chats before responding [14].
  • Anthropic says each Claude project has its own memory, and when Claude searches earlier chats, the search appears in the conversation as a tool call [13].

These products use stored information to shape later responses, but providers do not disclose every implementation detail. OpenAI says ChatGPT selects the stored information relevant to a given response rather than using everything [4], and Anthropic’s engineering guidance describes notes kept outside the context window being pulled back in when needed [3]. Whether a product also uses conversations to train future models is a separate policy question; Microsoft, for instance, says prompts and responses in its workplace Copilot are not used to train foundation models [8]. What Does AI Remember Between Messages—and What Does It Forget? covers these memory types and their controls in depth.

Retrieval Finds the Pages; Tools Do the Work

Retrieval

Retrieval answers one question: which few passages from a large collection should the model see? Microsoft describes retrieval-augmented generation as grounding a model’s responses in an organization’s own content, and says retrieval must return a small set of highly relevant results rather than whole documents [9]. The search behind it often matches meaning rather than exact wording, which semantic search and vector databases explains; RAG Explained covers the full pipeline.

Retrieval also carries a permissions problem. Microsoft notes that opening private content to a model requires granular access control, so users and agents retrieve only what they are authorized to see [9]. If retrieval ignores those rules, the model can faithfully summarize a document the user was never meant to read.

Tools

A tool lets the model hand a job to other software: a web search, a calculation in a code sandbox, a browser session, a database lookup or an action in an app. The model does not perform the job. It emits a structured call that names a tool and supplies arguments, and something else executes it [5, 6, 15].

Who executes it depends on the design:

  • In OpenAI’s function-calling flow, the developer’s application runs the requested function and sends the output back, after which the model answers or asks for another tool [6].
  • Google’s Gemini documentation states that the model doesn’t execute the function; the application extracts the name and arguments and runs it [15].
  • Anthropic separates client tools, run by the developer’s application, from server tools such as web search, web fetch and code execution, which run on Anthropic’s own infrastructure [5].

Toolkits now reach well beyond search: OpenAI’s built-in tools include file search over uploaded files, a shell for running commands and computer use [11]. Connections to outside apps can use shared standards such as the Model Context Protocol (MCP), an open-source standard for linking AI applications to data sources, tools and workflows [16]. The previous guide, How Does AI Use Search, Code, Browsers, Apps, and Other Tools?, walks through that cycle and its risks.

The Application Layer Sets the Rules

The application layer is the product built around the model. Three mechanisms do most of its work.

System instructions. Microsoft defines a system message as instructions and context given to the model to guide its responses, such as its role, boundaries, tone and output format [7]. It also warns that a system message influences the model without guaranteeing compliance and should be layered with safeguards such as filtering and evaluation [7].

Instruction priority. Some providers publish how their models should weigh conflicting instructions. OpenAI’s Model Spec, in its version dated October 29, 2026, gives developer messages more authority than user messages and says instructions found inside tool outputs, quoted text or files should be treated as information, not commands [17]. Other providers use their own schemes; How Does AI Follow Instructions? explains how system prompts, instruction tuning and rules fit together.

Permissions. Some rules are enforced by ordinary software rather than by the model. Microsoft says its workplace Copilot surfaces only organizational data that the individual user already has at least view permission to access [8]. A rule like that holds whether or not the model behaves as intended, which is why it belongs outside the model.

One Request, Start to Finish

This is an illustrative scenario, not a description of any real product or a recorded answer. The owner of a small online shop uses an AI assistant connected to her company files, with web search and a code tool switched on. She asks it to compare her shop’s shipping-rate sheet with the rates her carrier currently publishes, and to estimate what last month’s orders would have cost under each.

  1. The application assembles the context: its system instructions, the conversation so far and a saved preference from an earlier session, such as showing figures in Canadian dollars [1, 4]. If that preference is out of date, the whole answer inherits the error.
  2. Retrieval finds the internal rate sheet, filtered by her access rights, and places the relevant passage in the context [9]. If an older version ranks higher, the comparison starts from the wrong baseline.
  3. The model requests a web search, because its parameters cannot be relied on for the carrier’s current prices; the provider or the application runs it [5, 10]. A page listing outdated rates, or one carrying hidden instructions, now sits in the context too [12].
  4. The model requests a code run, writing a short calculation over last month’s orders for a code tool to execute [5, 11]. A misread column produces a precise-looking wrong total.
  5. The model writes the answer from everything now in the context, ideally pointing to the rate sheet, the carrier page and the calculation. Any earlier failure can reach this step and still read confidently.
  6. The owner checks it, opening the carrier page and the calculation before changing her prices, because no single row of the map guarantees a correct result.

Here a person made the final call. When a system repeats the request, run and review cycle many times toward a goal with fewer human checkpoints, it moves into the territory of AI agents.

Why the Whole System Matters for Trust

Because every row can fail, a fluent answer tells you little about which rows did their job. OWASP describes indirect prompt injection as what happens when a model accepts input from external sources such as websites or files, which can carry instructions the user never wrote [12]. Its recommended defenses sit largely outside the model: limit the model’s access to the minimum it needs, and require human approval for privileged operations [12].

OpenAI’s specification tells its models to treat such embedded instructions as information [17], but as Microsoft notes for system messages, model-level rules need backing from filtering and evaluation [7].

Researchers at Berkeley call this arrangement a compound AI system: one that handles a task through several interacting parts, such as multiple model calls, retrievers or tools [18]. Whatever the label, judging “the AI” means judging the whole chain.

Where the Chapter Goes Next

This guide closes How AI Works, which began with how AI turns an input into an answer. Two chapters build directly on it:

  • AI Models + Systems turns to the models themselves: families such as language, reasoning and multimodal models, and how they differ.
  • AI Agents + Autonomy follows systems that plan, use tools and check results over many steps with less human involvement.

Practical Takeaways

  • When an answer surprises you, trace it to a row of the map: training, conversation, saved memory, a retrieved document, a tool result or the application’s rules.
  • For anything recent, local or personal, look for signs that information was supplied at answer time, such as a citation, a search step or a file reference.
  • Review an assistant’s saved memories now and then; deleting a chat may not delete what was saved from it.
  • Treat web pages, files and tool results as material to check, not instructions an assistant should obey.
  • Give connected assistants the narrowest access to files and apps that still gets the job done.
  • Before acting on an important answer, open the source behind it; the more that rides on it, the closer the look.

Next in the curriculum: the AI Models + Systems chapter, starting with The Modern AI Model Map, and then AI Agents + Autonomy, starting with What Is an AI Agent?

Sources

  1. Context windows. Anthropic (Claude Platform Docs), accessed 2026-11-10.
  2. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. arXiv (NeurIPS 2020), 2020-05-22, accessed 2026-11-10.
  3. Effective context engineering for AI agents. Anthropic (Engineering blog), 2025-09-29, accessed 2026-11-10.
  4. Memory in ChatGPT. OpenAI Help Center (Internet Archive capture of 2026-10-26), accessed 2026-11-10.
  5. Tool use with Claude. Anthropic (Claude Platform Docs), accessed 2026-11-10.
  6. Function calling. OpenAI (API docs), accessed 2026-11-10.
  7. System message design for Azure OpenAI – Microsoft Foundry. Microsoft Learn, 2026-05-13, accessed 2026-11-10.
  8. Data, Privacy, and Security for Microsoft Copilot. Microsoft Learn, 2026-07-09, accessed 2026-11-10.
  9. RAG and Generative AI – Azure AI Search. Microsoft Learn, 2026-08-04, accessed 2026-11-10.
  10. Grounding with Google Search. Google (Gemini API docs), accessed 2026-11-10.
  11. Using tools. OpenAI (API docs), accessed 2026-11-10.
  12. LLM01:2025 Prompt Injection. OWASP Foundation (GenAI Security Project), 2025, accessed 2026-11-10.
  13. Use Claude's chat search and memory to build on previous context. Anthropic (Claude Help Center), accessed 2026-11-10.
  14. Save info and reference past chats in Gemini Apps. Google (Gemini Apps Help), accessed 2026-11-10.
  15. Function calling. Google (Gemini API docs), accessed 2026-11-10.
  16. What is the Model Context Protocol (MCP)?. Model Context Protocol (official documentation), accessed 2026-11-10.
  17. OpenAI Model Spec (2026-10-29 version). OpenAI, 2026-10-29, accessed 2026-11-10.
  18. The Shift from Models to Compound AI Systems. Berkeley Artificial Intelligence Research (BAIR) Blog, 2024-02-18, accessed 2026-11-10.