Typed state records
Every candidate record should carry type, source, provenance, freshness, authority, dependency, and risk metadata so the optimizer can reason over state rather than raw text.
Needlepath turns context management into an infrastructure primitive: select the right state, preserve grounding, fail open when needed, and measure every high-volume agent workflow.
Production agents do not fail only because they lack context. They also fail because they carry stale chat history, distractor retrieval chunks, unused tool schemas, redundant memories, workflow traces, file metadata, and partial results into model calls. Needlepath treats context selection as an infrastructure concern: preserve grounding-critical evidence, remove low-signal state, and fail open when optimization would be risky.
Needlepath sits between the agent runtime and the model call. It evaluates the next action, scores candidate state records against the task, preserves constraints such as citations, identifiers, workflow dependencies, policies, and output contracts, then returns either an optimized context package or a safe baseline pass-through decision.
Needlepath operates before token-level compression. It decides which state belongs in the run at all. Compact encodings, provider caching, and prompt compression can then make the retained payload denser, cheaper, or faster. That distinction matters because the dominant production risk is often not excessive text alone, but the wrong state being sent to the model.
The paper argues for production-conservative rollout: replay real customer traces, track savings, latency, fallback, and quality by workflow, and promote only workflows that clear governance gates. The goal is not token reduction in isolation. The goal is lower cost and latency while preserving correctness, grounding, policy boundaries, and output completeness.
Every candidate record should carry type, source, provenance, freshness, authority, dependency, and risk metadata so the optimizer can reason over state rather than raw text.
Needlepath protects evidence, citations, identifiers, workflow state, policy context, and output contracts before optimizing for token budget.
When optimization is unsafe, the system should explain why it declined and use baseline context instead of silently degrading the run.