ARCHITECTURE · CONTEXT ENGINEERING · 5 MIN READ
A context pipeline for a long-running agent
Select the right instructions, evidence, and state for each turn.
Treat context as a compiled input
Gather the current task, relevant memories, recent tool results, and application instructions. Rank and filter each source, then build the input within a token budget. Preserve the distinction between trusted instructions and retrieved data.
Compact with a purpose
A summary should preserve decisions, unresolved questions, resource identifiers, and evidence needed to continue. Store references to large artifacts instead of repeatedly inserting their full contents. Test whether compaction removes information required later.
Measure useful context
Track retrieval relevance, repeated context, token use, and task success. A smaller prompt is only an improvement if the agent retains the information it needs to complete the task correctly.