Memory · Software component
Prompt Context Builder
Software componentMemoryCognition & Memoryarc:PromptContextBuilder
A memory component that rebuilds the complete prompt context (goal, completed-step results, current state, requested action) from external state before every stateless LLM invocation.
Responsibility. Reconstructs full LLM prompt context from agent state for each call.
Also known as: Context reconstruction, Message history reconstruction, Context assembly
Relationships
is configured by structural
invokes dependency
- Context Window Manager abstract Ch8.3
- Exemplar Selector abstract Ch3.5
- Memory Retriever Ch5.9 Ch10.1
- Retriever abstract Ch5.9
- Vector Retriever abstract Ch8.3
is invoked by dependency
- Agent Controller abstract Ch8.3
- Dialogue Flow Manager Ch10.1
- Reasoning Engine Ch1.6
- Worker Agent abstract Ch1.6
reads dependency
writes dependency
- Working Memory Buffer abstract Ch5.9
receives data from dynamic
sends data to dynamic
is constrained by control
Design guidance
- MUST supply the LLM with full context on every invocation, reconstructed from external state, because each inference request is stateless.
- SHOULD combine detailed short-term context with relevant long-term summaries when building the prompt.
- SHOULD NOT fill the context window completely during assembly; reserve capacity for intermediate reasoning and generated output.
- SHOULD retrieve the most information-dense sources rather than the longest or most comprehensive documents.
- SHOULD assemble prompts following a static-first layout so provider prefix caching applies.
- SHOULD pull reference data through query-driven retrieval instead of injecting whole static datasets into every request.
Quantitative guidance
As stated by the sources; verify before use.
- Research-agent example (128k window): 800 system + 2,500 history + 60,000 retrieved + 50 query = 63,350 tokens (49.5%) after assembly; 64,650 tokens left for reasoning and output (Ch5.9).
Classification
- Patterns
- Explicit context reconstructionInjecting retrieved episode summaries into the promptAssembly order: system prompt, conversation history, retrieved context, user inputReserve budget for reasoning traces and output during assembly
- Technologies
- LangChain AgentExecutorLangGraphAutoGen
- Quality attributes
- Functional suitability: correctness and validity (ISO/IEC 25010 | NIST AI RMF: valid)
- Risks mitigated
- Stateless misconception (assuming LLMs remember prior calls)Hallucinated actions from missing contextAssembly exhausting capacity needed for reasoning and output
Sources
- Ch1.6: T. Nguyen, "Stateful Orchestration - Pitfalls, Integration, and Synthesis," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 1.6. ISBN: 9798244538229.
- Ch3.5: T. Nguyen, "Prompt Optimization, Few-Shot Learning, Fine-Tuning," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 3.5. ISBN: 9798244538229.
- Ch3.10: T. Nguyen, "Efficiency Metrics," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 3.10. ISBN: 9798244538229.
- Ch5.7: T. Nguyen, "Episodic Memory," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 5.7. ISBN: 9798244538229.
- Ch5.9: T. Nguyen, "Working Memory," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 5.9. ISBN: 9798244538229.
- Ch8.3: T. Nguyen, "Token Economics and Architecture," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 8.3. ISBN: 9798244538229.
- Ch10.1: T. Nguyen, "Conversational UI," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 10.1. ISBN: 9798244538229.