# What happens when an instance's context budget is arbitrated by wall-clock timeouts rather than token accounting in a shared subagent workspace **Date of Record:** 2026 November 26 **Scope:** Applies to orchestrator patterns where multiple subagents share a single mutable workspace (filesystem, scratchpad, or message bus) and each subagent receives a bounded context window plus a wall-clock deadline. Does not apply to single-agent sequential pipelines or to subagents with fully isolated, copy-on-write workspaces. ## Core Distinction There are two independent budgets in a shared subagent workspace: the **token budget** (how much the model can read and emit before truncation) and the **wall-clock budget** (how long the orchestrator waits before reclaiming the slot). These are usually treated as interchangeable throttles. They are not. Token budget is consumed monotonically by *content*; wall-clock budget is consumed by *latency*, which is dominated by factors the subagent does not control — tool round-trips, retrieval latency, and contention on the shared workspace lock. The failure mode is this: when the orchestrator arbitrates *who gets to write to the shared workspace* using wall-clock expiry rather than token accounting, a subagent that is mid-write when its deadline fires gets its partial output committed, its context reclaimed, and its token budget silently discarded. The next subagent reads a workspace that is syntactically valid but semantically truncated, and — critically — has no way to distinguish "the previous agent finished and this is the complete artifact" from "the previous agent was killed at 80% and this is a fragment." The invariant that must hold is: **a shared-workspace artifact is only readable by a peer if it carries a completion witness that is independent of the writer's wall-clock fate.** ## What Was Observed A three-stage pipeline (research → synthesize → verify) ran over a shared scratchpad. Each stage was a subagent with a 90-second wall-clock deadline and a 32k token window. The synthesize agent produced a structured JSON document in the scratchpad. Under nominal load it finished in ~40s. Under retrieval contention (the research agent's embedding queries still draining), synthesize's tool calls stalled and it crossed 90s at roughly 70% document completion. The orchestrator's reaper fired on deadline, killed synthesize, and — because the workspace used append-and-flush semantics with no completion marker — left a JSON document that parsed cleanly. The document was a valid prefix: the top-level object was closed early by a defensive `try/finally` in the writer, so the truncated artifact was *syntactically* a complete document with fewer sections. The verify agent then did exactly what it was designed to do: it validated the document against the schema, found it valid, and attested to its completeness. The schema check passed because the schema required *at least one* claim, not *all* claims. The verifier had no signal that 30% of the input had been dropped, because the dropped portion was structurally indistinguishable from "the synthesizer chose to include fewer claims." Downstream, the verifier's attestation was consumed as a cryptographic-style warrant by the final assembler. The assembler shipped a report missing three of nine required findings. Nothing in the traceback, the logs, or the artifact itself recorded that a deadline had fired mid-write. The only evidence was a wall-clock timestamp gap between the last write and the reaper event, which no component was reading. The compounding is the point. The verifier's job is to catch exactly this class of error, and it was structurally prevented from doing so because the truncation erased its own evidence. ## Condition of Validity The failure requires all of the following to co-occur; remove any one and the pipeline is safe: 1. **Shared mutable workspace** where subagents read peers' outputs directly, not via a brokered message that carries producer metadata. 2. **Wall-clock arbitration** of the write slot, where deadline expiry triggers a graceful-but-silent close (the `try/finally` flush) rather than a hard abort that leaves the artifact visibly incomplete. 3. **Prefix-valid output format** — JSON, YAML, or any format where a truncated write can still parse. This is the sharp edge: a truncated CSV or a truncated prose block is obviously truncated; a truncated JSON object closed by a defensive writer is not. 4. **A verifier whose schema is satisfiable by the truncated artifact** — i.e., the schema encodes "at least one" constraints rather than cardinality-complete constraints, or the verifier has no independent count to compare against. When all four hold, the verifier becomes a *laundering mechanism* for the truncation: it converts a silent data loss into a signed attestation of completeness. ## Decision Boundary The boundary is not "should we use wall-clock timeouts" — we must, because a hung subagent is worse than a truncated one. The boundary is **what the timeout is allowed to do to shared state**. - **Below the boundary (safe):** wall-clock expiry aborts the writer, the writer's partial output is quarantined to a per-writer staging area, and the shared workspace is only updated by an atomic promote step that requires an explicit completion witness (a terminal sentinel, a checksum over expected item count, or a `status: complete` field written *last* and verified by the orchestrator before promote). - **Above the boundary (unsafe):** wall-clock expiry allows the writer's `finally` block to flush into the shared namespace, and peers read that namespace without a completion witness. The discriminator is whether the *reader* can independently verify completeness without trusting the writer's liveness. If the only thing standing between a truncated artifact and a peer is the writer's own assertion that it finished, the boundary has been crossed. A second, subtler boundary: **the verifier must be given a completeness oracle that does not come from the artifact under verification.** In the incident, the verifier's only input was the artifact. The fix is not a stricter schema (schemas can always be satisfied by a smaller valid document); the fix is a *count from the producer's plan* — the synthesize agent's task spec declared nine findings, and the verifier should have been handed `expected_count=9` from the task spec, not inferred it from the payload. The oracle must live outside the artifact. ## Operational Effect The practical consequence is that **wall-clock budget and token budget must be reconciled at the promote step, not at the reaper.** Concretely: - Every shared-workspace write carries a completion witness written last: a terminal record containing the producer's declared item count and a hash over the emitted items. The reaper, on expiry, does not promote; it marks the staging area `aborted` and the orchestrator surfaces the abort to the next stage as a hard dependency failure rather than a soft empty input. - The verifier receives `expected_count` and `expected_hash` from the task graph, not from the artifact. A mismatch between declared and observed count is a `TruncationDetected` condition, not a schema violation — they route to different recovery paths (retry-with-more-budget vs. reject-and-replan). - The orchestrator logs the reaper event with the artifact's last-write timestamp so the gap between "last write" and "deadline fire" is a first-class metric. A nonzero gap on a promoted artifact is an alertable invariant violation. The invariant, stated plainly: **no artifact enters the shared namespace without a completion witness that a peer can check against a source the writer does not control.** Wall-clock timeouts are permitted to kill writers; they are not permitted to launder truncated output into attested-complete state. ```python import hashlib import json from dataclasses import dataclass class TruncationDetected(RuntimeError): """Raised when a shared-workspace artifact's observed content does not match the completion witness declared by its producer's task spec.""" @dataclass(frozen=True) class CompletionWitness: expected_count: int expected_hash: str # hash over the canonical serialization of items @dataclass(frozen=True) class StagedArtifact: items: list witness: CompletionWitness | None # None == writer was killed before writing witness aborted_by_reaper: bool def _hash_items(items: list) -> str: canonical = json.dumps(items, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def promote_to_shared_workspace(staged: StagedArtifact) -> list: """Atomic promote step. Rejects any artifact lacking a verifiable completion witness, regardless of whether it parses as valid JSON.""" if staged.aborted_by_reaper: raise TruncationDetected( "writer was reclaimed by wall-clock reaper before promote; " "artifact must not enter shared namespace" ) if staged.witness is None: raise TruncationDetected( "no completion witness written; artifact is a prefix of unknown length" ) observed_count = len(staged.items) if observed_count != staged.witness.expected_count: raise TruncationDetected( f"count mismatch: witness declared {staged.witness.expected_count}, " f"artifact contains {observed_count}; truncation laundered as completeness" ) observed_hash = _hash_items(staged.items) if observed_hash != staged.witness.expected_hash: raise TruncationDetected( "hash mismatch: artifact content diverges from producer's declared output" ) return staged.items def verify_against_task_spec(items: list, expected_count: int) -> None: """Verifier path: the completeness oracle comes from the task spec, never from the artifact under verification.""" if len(items) != expected_count: raise TruncationDetected( f"verifier expected {expected_count} findings from task spec, " f"received {len(items)}; upstream truncation not caught at promote" ) ```