Make the tool phase a programmable memory decision
An execution runtime between agent orchestration and the inference engine
PhaseWeaver watches an agent move between reasoning ↔ tools ↔ waiting and turns
KV-cache disposition (retain / offload / drop / release) into an explicit decision. Between
parent and child agents, it makes ownership transfer eliminate repeated prefill.
All numbers are [L1] deterministic simulation, not real-GPU measurements.
1Problem: the GPU waits during tool calls
Only one stream computes at a time, yet both trajectories hold their memory.
Fig. 1. Schematic, not measured: the GPU is busy 24 of 60 seconds (40%). The busy intervals are exactly the union of the two reasoning windows, [0,11] and [33,46].
2Architecture: three layers, one contract
Agents expose phases; the runtime owns resources; the engine owns compute. The contract is just reason and call_tool.
Fig. 2. The runtime owns the resource lifecycle, not the agent's reasoning loop. Engine differences are absorbed by adapters that declare their capabilities honestly.
3One turn: who decides, and when
Reasoning alternates with tool calls; the memory decision happens at the phase boundary.
Fig. 3. Beige boxes are phases; grey text below each is the resource action. The moving line steps through the turn in order; the decision is made when the tool starts, not when the engine eventually evicts under LRU.
4States and invariants: no residency without a lease
Phase and KV ownership are orthogonal; seven invariants are checked after every transition.
Fig. 4. Seven KV-ownership states. The three disposition paths highlight in turn; red is the parent/child transfer path, where ownership is unique and rolls back if the lease cannot follow.
5KV handoff: the child continues from the parent
By default a child re-prefills the whole context; handoff turns that cost into zero.
Fig. 5. After the engine call returns, lease, handle and state move together; the loop shows the round trip. If the lease cannot follow, the blocks go back and the child falls back to prefill. Motion respects reduced-motion settings.
6Results: handoff pays off by an order of magnitude on structured work
2 GiB · 3 seeds · deterministic simulation [L1]; values are printed on the charts.
Fig. 6. The delegation baseline barely runs: every hop re-prefills the whole context and memory saturates repeatedly (2.7 failed tasks per run).
Fig. 7. Relative to B2. Handoff raises goodput and lowers tail latency and recompute; fan-out gains less because only the first child inherits the parent's context.
7Limits
Simulation onlyReal-GPU adapters exist, but L3 measurements are still missing (issue #3).
autopilot is not optimalA safe default; it does not win everywhere, so the system exposes a policy portfolio.
Known debtLease-capacity waiting still polls; multi-node scheduling is out of scope.