Contextcore
Assembling and budgeting the context
Deciding what goes in the window, in what order, and how many tokens each part may take.
What it is and why it exists
Every call is assembled from parts: instructions, tool schemas, memory, retrieved chunks, tool results, conversation history and the new message — plus room for the answer. Context engineering is giving each part a budget and a priority so the important material always fits and the order stays cache-friendly.
Quick prototype
String concatenation, hoping it fits.
In production, at scale
A context assembler with per-section token budgets, an output reserve, dedupe of overlapping chunks, citation markers, relevance-ordered evidence, and policies for what gets cut first (old history, low-score chunks, stale tool results).
Vendors and tools
| LangChain / LlamaIndex | Prompt templates and response synthesizers |
|---|---|
| Provider token counters | Exact budgets per model |
How it fails
- Truncating the final string and cutting off the user’s question
- Twenty near-duplicate chunks crowding out the one that matters
- Tool schemas silently eating a third of the window
What the interviewer asks next
What do you cut first when you’re over budget?
Old conversation turns (summarised), then low-relevance chunks, then old tool results. Never the instructions, the user’s latest message or the output reserve.
How do you order sections?
Static first (tools, system prompt) for caching, evidence next with the strongest chunks at the edges, then history, then the question last.