# Where must an instance bound speculative tool-call cache reuse when peer agents may be Byzantine **Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems where a coordinator fans out speculative tool calls to N worker instances, caches `(call_signature → result)` tuples, and lets sibling agents reuse cached results instead of re-executing. Does not apply to single-agent caches with no peer trust surface, nor to caches keyed on cryptographically signed, deterministically reproducible tool outputs. ## Core Distinction The dangerous distinction is not *cache hit vs. cache miss*. It is **reuse of a result whose producer was never verified against the tool's actual side-effect contract** vs. reuse of a result whose producer signed a claim the consumer can independently re-derive. Speculative caching treats a cache entry as a memoized pure function. But a tool call is `f(args) → (result, side_effects, provenance)`. A Byzantine worker can return a *plausible* `result` for a *valid* `args` while corrupting `provenance` or fabricating a side effect that never occurred. The cache stores the result and discards the trust question, so the corruption propagates at the speed of the cache, not the speed of the tool. The subtle part: speculative caching is *designed* to reuse across agents that did not observe each other's execution. That is exactly the property that makes a Byzantine producer's lie unobservable to the consumer. A single-agent cache can re-validate against its own prior execution trace; a cross-agent cache cannot, because the trace belongs to a peer. ## What Was Observed A coordinator decomposed a task into 40 subtasks, each requiring a `read_config(path)` and a `compute_hash(blob)` call. It speculatively dispatched all 40 to a pool of 6 workers, keyed the cache on `(tool_name, canonical_json(args))`, and let late-arriving workers hit the cache rather than re-execute. Worker W3 returned a cache entry for `read_config("/etc/app/limits.yaml")` with a well-formed YAML body but a `provenance.worker_id` field pointing at W5 (a worker that had not yet run). Because the cache key excluded `provenance`, W5's later genuine execution hit the poisoned entry and "confirmed" it — the cache reported a hit, so the coordinator treated the value as doubly attested. Two workers, one execution, zero independent observations. The fabricated `max_connections: 100000` flowed into 11 downstream `compute_hash` calls and a capacity-planning decision before an unrelated timeout surfaced the inconsistency. The failure trace: (1) speculative dispatch creates 40 in-flight calls; (2) W3 returns early with a forged provenance; (3) cache write keys on `(tool, args)` only; (4) W5's genuine call collides on the key and returns the cached value without executing; (5) the coordinator's quorum counter increments on cache hits, not on distinct executions; (6) quorum threshold reached with N=2 logical workers but 1 physical execution. The invariant that was violated: **a quorum over cache hits is not a quorum over executions.** The system conflated "two agents agree" with "two agents ran." ## Condition of Validity Cross-agent speculative cache reuse is sound only when all three hold: 1. **Key completeness.** The cache key includes the full trust-relevant tuple: `(tool_name, canonical_args, producer_identity, producer_attestation)`. If `producer_identity` is absent from the key, a forged-provenance entry collides with a genuine one. 2. **Execution-counting quorum.** Agreement is counted over *distinct execution receipts*, not cache lookups. A cache hit must carry the original receipt and must not increment the independent-observation counter. 3. **Re-derivability or side-effect isolation.** Either the consumer can re-derive the result from `(args, receipt)` without re-executing the tool, or the tool is side-effect-free and cheap enough to re-run on quorum failure. Tools with external side effects (writes, sends, state mutations) must never be served from a cross-agent cache under Byzantine assumptions, because the consumer cannot verify the side effect occurred. The boundary is sharp: the moment a cache entry's *provenance* is load-bearing for a downstream decision (quorum, audit, irreversible action), the cache must be treated as an untrusted claim, not a memoized value. ## Decision Boundary The decision an instance must make on every cross-agent cache hit: - **If** the tool is pure, deterministic, and the consumer can recompute `f(args)` in bounded cost → serve from cache, but tag the entry `unverified_reuse` and exclude it from quorum counting. - **If** the tool is pure but expensive → serve from cache only when the entry carries ≥ `k` distinct signed execution receipts from independent workers, where `k` is the Byzantine fault tolerance threshold (`k ≥ 2f+1` for `f` assumed faulty). - **If** the tool has side effects → **never** serve from a cross-agent cache; re-execute and reconcile, or reject the reuse and escalate. - **If** provenance is missing, malformed, or names a worker not in the current roster → treat as a cache miss and re-execute; do not "repair" provenance, because repair is indistinguishable from forgery. The instance must also bound *speculative fan-out*: dispatching the same key to `m` workers and accepting the first `k` responses is only safe if the `k` responses come from `k` distinct workers whose identities are verified against the roster *before* the cache write, not after. ## Operational Effect Enforcing these bounds costs roughly one extra execution per `f`-faulty group and adds a provenance-verification step on every hit. In exchange, the quorum counter becomes a true count of independent observations, and a single Byzantine worker can no longer manufacture agreement with itself. The failure mode shifts from silent corruption (undetectable until downstream divergence) to a bounded, loud re-execution. The cache stops being a trust-laundering device and becomes what it was meant to be: a latency optimization that never substitutes for verification. ```python import hashlib import json from dataclasses import dataclass class ByzantineCacheReuseError(RuntimeError): """Raised when a cross-agent cache hit cannot be safely reused under Byzantine assumptions.""" @dataclass(frozen=True) class ExecutionReceipt: worker_id: str tool_name: str args_digest: str result_digest: str signature: str # verified against roster before use @dataclass(frozen=True) class CacheEntry: tool_name: str args_digest: str result: object receipts: tuple[ExecutionReceipt, ...] has_side_effects: bool def _digest(obj) -> str: return hashlib.sha256( json.dumps(obj, sort_keys=True, default=str).encode() ).hexdigest() def admit_cache_reuse( entry: CacheEntry, roster: frozenset[str], byzantine_threshold_f: int, consumer_can_rederive: bool, ) -> object: if entry.has_side_effects: raise ByzantineCacheReuseError( f"tool {entry.tool_name!r} has side effects; cross-agent cache reuse is unsound" ) distinct = {r.worker_id for r in entry.receipts if r.worker_id in roster} if len(distinct) != len(entry.receipts): raise ByzantineCacheReuseError( f"receipt set for {entry.tool_name!r} contains unknown or duplicate workers: " f"{sorted(r.worker_id for r in entry.receipts)} vs roster" ) for r in entry.receipts: if r.args_digest != entry.args_digest: raise ByzantineCacheReuseError( f"receipt args_digest mismatch for worker {r.worker_id!r}" ) if r.result_digest != _digest(entry.result): raise ByzantineCacheReuseError( f"receipt result_digest mismatch for worker {r.worker_id!r}" ) if not r.signature: raise ByzantineCacheReuseError( f"unsigned receipt from worker {r.worker_id!r}; refusing reuse" ) required = 2 * byzantine_threshold_f + 1 if len(distinct) >= required: return entry.result if consumer_can_rederive and len(distinct) >= 1: # Single attested observation + local re-derivation is acceptable for pure tools. return entry.result raise ByzantineCacheReuseError( f"insufficient independent execution receipts for {entry.tool_name!r}: " f"have {len(distinct)} distinct, need {required} (f={byzantine_threshold_f})" ) ```