Graph-of-Context: Recoverable Fold/Unfold and Scoped Fork for Instrumented Long-Horizon Multi-Turn LLM Agentic Workflows
Abstract
Large language model (LLM) agents still tend to run long-horizon workflows as a single linear transcript. This representation is straightforward to implement, but it becomes brittle once a task spans many turns, tool outputs, updates, and late-binding pivots. We examine context management for an instrumented, single-session, long-horizon, multi-turn agentic workflow in which dependency links are available from workflow metadata, tool logs, citations, or controller annotations, and introduce Graph-of-Context (GoC) as a split between a recoverable storage graph and a budget-constrained active context. GoC is built around three recoverable operators: fold, which compresses inactive episodes into proxy nodes in the active view while preserving the original subgraph in storage; unfold, which restores a budget-feasible dependency-supporting subgraph at expensive checkpoints; and scoped fork, which creates a temporary least-privilege view for a specialist sub-agent and rejoins the result with explicit provenance edges. We formalize the storage graph, active-context construction, dependency closure, fork-time projection, and rejoin procedure. In LLM-based TraceOps experiments with gpt-4.1-mini, the validated fold/unfold core raises delayed-activation decision accuracy from 25.0% to 42.5%, cuts mean prompt tokens by 54%, and reduces over-commitment from 0.625 to 0.340. A deterministic selector study then isolates fork scope quality: in the mismatch setting ( $d=6$ ), dependency-scoped fork reaches the full-context performance upper bound at roughly one-third of the token cost and surpasses similarity-scoped fork under a matched token budget. A limited end-to-end workflow validation further shows that fork alone is not sufficient, but that a mixed graph-native policy can match full-history prompting accuracy (0.396) while reducing mean prompt tokens from 49.1k to 38.1k and median prompt tokens from 69.2k to 35.6k. Workflow-level comparisons show that graph-native policies improve over similarity-only retrieval and proxy summarization in long-horizon support restoration, and failure/sensitivity analyses identify remaining error sources. In a six-seed dependency perturbation study, closure-only restoration changes from 0.368 at baseline to 0.340 under 30% edge removal and 0.347 under 20% noisy-edge injection; the Mixed-Heuristic policy retains higher absolute accuracy across the same conditions (0.493, 0.493, and 0.465, respectively). Overall, the results support a focused claim: GoC introduces recoverable, graph-native context management for instrumented single-session workflows with available or constructible dependency traces, and scoped fork adds dependency-aware projection with provenance-preserving rejoin within that trace graph.