Back

KV Capsules + PTI

Quality-gated attention-state reuse for local tool-using agents.

Local agents repeatedly pay to reread stable context: tool schemas, runtime rules, interface contracts, and task protocols that often do not change between related runs.

What I built

A KV Capsule harness that validates a stable prefix once, restores the resulting attention state, and appends fresh task tails without replaying the whole tool context as text.

A Programmatic Tool Interface layer that keeps plans and tool calls structured, plus a control ladder for comparing native append, restored KV, fresh-tail, and wrong-capsule behavior.

A BFCL-derived repeated-work evaluation stream designed to test whether stable local-agent context can be reused without leaking the wrong task state.

How it works

Stable tool and runtime context becomes a quality-gated capsule. When a related task arrives, the system restores that hidden KV state and appends only the fresh visible tail.

PTI constrains the model-side route through structured tool plans instead of leaving every call to free-form text.

The evaluation compares restored-state execution against a tested regular text-threaded local-agent harness using the same local model family, then checks negative controls for leakage.

What it proves

On the selected repeated-work stream, KV Capsules + PTI completed the 100-case run 13.8x faster: 14.2 minutes versus 3.28 hours for the tested regular text-threaded local-agent harness.

Restored KV + PTI completed 100/100 selected cases, while fresh-tail and wrong-capsule controls produced 0 leaks in the checked controls.

This is a practical runtime comparison, not a prompt-identical benchmark or official BFCL leaderboard claim. The result is intentionally scoped to the selected cohort, local Gemma 4 12B setup, and runtime contract tested in the paper.