OpenViking guides
Context engineering for agents: retrieval, memory, and assembly
Context engineering is the work of selecting, organizing, and delivering the information an AI model needs at each step. For agents, it includes instructions, retrieved evidence, tool results, conversation history, memory, and the rules for fitting them into a limited context window.
Start with the failure you want to fix
A missing source, an irrelevant retrieval result, an outdated preference, and a full context window are different failures. Record the query, selected sources, injected content, and result. Changing a prompt cannot repair information that was never available; increasing the context budget cannot establish which source is authoritative.
Retrieve progressively
Use a compact description to locate promising material, then load evidence in more detail. OpenViking offers L0 abstracts, L1 overviews, and L2 source content. An overview can help plan a task, but exact claims and code changes may require the original file. The agent should retain a source address so it can verify details later.
Assemble context deliberately
Keep stable instructions distinct from changing task context. Select relevant memory and recent messages within a budget instead of replaying every stored item. Context-engine integrations can participate in assembly, while simpler hooks inject retrieved blocks. The host's integration contract determines how much of the final prompt can be controlled.
Handle asynchronous work and compaction
When archival or summarization runs asynchronously, the next turn must still have access to messages the finished summary does not yet cover. Define the boundary between summarized history and active messages. Treat recalled text as evidence and historical context, with current instructions determining what work is authorized.
Run a small evaluation loop
Use representative tasks with known sources. Compare a baseline against the new retrieval and assembly policy. Track answer correctness, missed evidence, stale memory, input tokens, and latency. Include topic changes and resumed work. OpenViking supplies storage and retrieval primitives; the application remains responsible for testing its overall context policy.