> ## Documentation Index
> Fetch the complete documentation index at: https://university.gumloop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Context | AI Fundamentals

> How AI models use context as working memory — system prompts, user messages, tool results — and what happens when you run out of space.

<div id="gumloop-auth" data-token={user?.accessToken || ''} data-email={user?.email || ''} style={{display: 'none'}} />

<div className="lesson-page">
  <div className="lesson-breadcrumb">
    <a href="/">University</a>

    <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="chevron">
      <path d="m9 18 6-6-6-6" />
    </svg>

    <a href="/ai-fundamentals/what-is-an-ai-model">AI Fundamentals</a>

    <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="chevron">
      <path d="m9 18 6-6-6-6" />
    </svg>

    <span className="current">Context</span>
  </div>

  <div className="lesson-card">
    <h1 className="lesson-title">Context</h1>

    <p className="lesson-desc">Context is the working memory of a conversation. Everything the model knows when generating a response — your message, the conversation history, tool results — lives here.</p>

    <div className="lesson-content">
      <h2>What Is Context?</h2>

      <p>Think of context as a desk. Everything the AI model needs to think about sits on that desk: your question, the conversation so far, any instructions, tool definitions, and results from tool calls. The model reads everything on the desk before generating its response.</p>

      <p>The bigger the desk, the more the model can work with. But every desk has an edge — that's the <strong>context window</strong>, measured in tokens.</p>

      <table>
        <thead>
          <tr><th>What's on the desk</th><th>Where it comes from</th></tr>
        </thead>

        <tbody>
          <tr><td><strong>System prompt</strong></td><td>Instructions set by the tool creator (called "AI Instructions" in Gumloop)</td></tr>
          <tr><td><strong>User message</strong></td><td>What you type in the chat</td></tr>
          <tr><td><strong>Conversation history</strong></td><td>All previous messages in this thread</td></tr>
          <tr><td><strong>Tool definitions</strong></td><td>Names, descriptions, and parameters of available tools</td></tr>
          <tr><td><strong>Tool results</strong></td><td>Data returned from tool calls</td></tr>
          <tr><td><strong>Attachments</strong></td><td>Images, documents, or other files you've shared</td></tr>
        </tbody>
      </table>

      <h2>System and User Prompts</h2>

      <p>Two types of text shape every AI response:</p>

      <p><strong>System prompt (AI Instructions)</strong> — these are set by the person who built the agent. They define the agent's identity, workflow, and boundaries. The user never sees them, but the model reads them first, before anything else. In Gumloop, these are called "AI Instructions."</p>

      <p><strong>User prompt</strong> — this is what you actually type. It sits alongside the system prompt in the context. The model uses both to decide what to do next.</p>

      <div className="lesson-callout">
        <div className="lesson-callout-header">
          <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
            <path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" />

            <path d="M9 18h6" />

            <path d="M10 22h4" />
          </svg>

          <span>Multimodal context</span>
        </div>

        <p>Modern models can handle more than text. Images, PDFs, and even audio can be part of the context. When you upload a screenshot to an AI, it becomes tokens on the desk alongside your message.</p>
      </div>

      <h2>Including Context from Tools</h2>

      <p>Here's where context gets powerful. Without tools, the model can only work with what it was trained on and what you tell it. With tools, the model can <strong>pull in real data</strong> and add it to the desk.</p>

      <p>For example:</p>

      <ul>
        <li><strong>MCP tools</strong> — an agent calls your CRM and the contact details come back into the context. Now the model can reference actual data when composing its response.</li>
        <li><strong>Web search</strong> — the model searches the web, and the results land in the context. Now it has information beyond its training cutoff.</li>
        <li><strong>File reading</strong> — the model reads a document you've shared, and its contents become part of the working memory.</li>
      </ul>

      <p>This is why tools reduce hallucination: the model doesn't need to guess when it has real data on the desk.</p>

      <h2>Context Limits</h2>

      <p>Every model has a maximum context window — the total number of tokens it can handle at once. Current models range from around 8,000 tokens (small) to over 1,000,000 tokens (very large).</p>

      <p>When you hit the limit, things start to break:</p>

      <ul>
        <li><strong>Older messages get dropped</strong> — the system starts removing earlier parts of the conversation to make room for new content</li>
        <li><strong>Quality degrades</strong> — even before hitting hard limits, models tend to "forget" details buried deep in long contexts</li>
        <li><strong>Tool definitions eat space</strong> — connecting many tools means their descriptions take up context that could be used for conversation</li>
      </ul>

      <p>Smart context management matters. Instead of passing all data through the model's context, workflows can process data independently and only pass the results back — keeping context lean and costs down.</p>

      <div className="lesson-tip">
        <div className="lesson-tip-header">
          <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
            <path d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z" />

            <path d="m9 12 2 2 4-4" />
          </svg>

          <span>Keep it lean</span>
        </div>

        <p>Shorter instructions, fewer unnecessary tools, and fresh conversations for new topics — these simple habits keep your context clean and your model sharp.</p>
      </div>

      <form className="quiz-widget">
        <h3>Quiz: What happens when a conversation exceeds the context window?</h3>

        <input type="radio" name="q-quiz" id="q-q0" className="quiz-input" />

        <input type="radio" name="q-quiz" id="q-q1" className="quiz-input" />

        <input type="radio" name="q-quiz" id="q-q2" className="quiz-input" />

        <input type="checkbox" id="q-check" className="quiz-check-input" />

        <label htmlFor="q-q0" className="quiz-option">
          <span className="quiz-circle" />

          <span>The conversation ends and the model refuses to respond.</span>
        </label>

        <label htmlFor="q-q1" className="quiz-option">
          <span className="quiz-circle" />

          <span>The model automatically summarizes the conversation and continues normally.</span>
        </label>

        <label htmlFor="q-q2" className="quiz-option quiz-correct">
          <span className="quiz-circle" />

          <span>Older messages get dropped and quality degrades as the model loses track of earlier details.</span>
        </label>

        <div className="quiz-explain-correct quiz-explanation">
          Correct! When context fills up, the system drops older messages to make room. Even before hitting the hard limit, models tend to "forget" details buried deep in long conversations.
        </div>

        <div className="quiz-explain-wrong quiz-explanation">
          Not quite. Think about the context window like a desk — what happens when you run out of space and keep piling on?
        </div>

        <div className="quiz-actions">
          <label htmlFor="q-check" className="quiz-check-btn">Check</label>
          <button type="reset" className="quiz-reset-btn">↺ Reset</button>
        </div>
      </form>
    </div>
  </div>

  <div className="lesson-nav-grid">
    <a href="/ai-fundamentals/tokens-and-costs" className="lesson-nav-card">
      <span className="nav-label">
        <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
          <path d="M19 12H5" />

          <path d="m12 19-7-7 7-7" />
        </svg>

        Previous Lesson
      </span>

      <span className="nav-title">Tokens & Costs</span>
    </a>

    <a href="/ai-fundamentals/giving-your-chatbot-tools" className="lesson-nav-card lesson-nav-next">
      <span className="nav-label">
        Next Lesson

        <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
          <path d="M5 12h14" />

          <path d="m12 5 7 7-7 7" />
        </svg>
      </span>

      <span className="nav-title">Giving Your Chatbot Tools</span>
    </a>
  </div>
</div>
