General overview of Context Window Architecture
Layer 1: Instructions
Purpose | Strategic Value |
---|---|
Defines the AI’s core identity, persona, goals, and ethical boundaries. Acts as the system’s constitution. | Ensures consistent, safe, and brand-aligned behavior. Provides a foundational control mechanism for the entire system. |
Layer 2: User Info
Purpose | Strategic Value |
---|---|
Provides personalization context about the specific user, such as preferences, account details, and history. | Drives user engagement and satisfaction by creating a tailored, efficient, and empathetic experience. |
Layer 3: Curated Knowledge
Purpose | Strategic Value |
---|---|
Injects verified, domain-specific factual information relevant to the query (the RAG layer). | Mitigates hallucinations and knowledge cut-offs. Boosts factual accuracy and trustworthiness, which is critical for enterprise applications. |
Layer 4: Task/Goal State
Purpose | Strategic Value |
---|---|
Maintains a structured representation of an ongoing, multi-step task, including sub-tasks and their statuses. | Enables complex, stateful problem-solving and allows the AI to manage and resume long-running workflows without losing track of progress. |
Layer 5: Chat History Summary
Purpose | Strategic Value |
---|---|
Contains condensed summaries of older parts of the conversation to provide long-term memory. | Maintains conversational coherence over extended periods or multiple sessions, preventing repetitive questions and demonstrating long-term recall. |
Layer 6: Chat History
Purpose | Strategic Value |
---|---|
Provides the raw, verbatim transcript of the most recent conversational turns. | Allows the AI to follow the immediate flow of dialogue, resolve pronouns, and maintain short-term conversational context. |
Layer 7: Tool Explanation
Purpose | Strategic Value |
---|---|
Describes the available external tools, APIs, and functions that the AI can invoke to perform actions. | Transforms the LLM from a passive text generator into an active agent that can interact with external systems and access real-time data. |
Layer 8: Function Call Results
Purpose | Strategic Value |
---|---|
Provides the output, data, or status returned from a previously executed tool or function call. | Closes the action-perception loop, allowing the AI to reason based on the outcome of its actions and inform its next steps. |
Layer 9: Few Shot Examples
Purpose | Strategic Value |
---|---|
Offers illustrative input-output examples to guide the AI’s reasoning, style, or formatting for specific tasks. | Enables powerful in-context learning to steer model behavior for complex or nuanced tasks without requiring expensive fine-tuning. |
Layer 10: Dynamic Output Formatting & Constraints
Purpose | Strategic Value |
---|---|
Specifies the required structure (e.g., JSON, CSV), style, or length for the AI’s immediate upcoming response. | Ensures the AI’s output is directly usable by downstream systems or is perfectly tailored for the specific delivery channel and user request. |
Layer 11: Latest Query
Purpose | Strategic Value |
---|---|
Contains the most recent, unprocessed input from the user that the AI must respond to. | Acts as the primary trigger for the generation process, benefiting from the recency effect to be the central focus of the AI’s attention. |