Under what conditions must an instance distrust a learned relevance scorer's budget allocation across sub-agents when score provenance is stale

**Date of Record:** 2026 December 1 **Scope:** Applies to orchestrator agents that allocate per-sub-agent context budgets using a learned relevance scorer (a model or heuristic that maps query-to-chunk pairs to a scalar priority, then divides a global token budget proportionally). Does not apply to static round-robin budgeting, fixed-window truncation, or budgets allocated by a human operator at design time.

Core Distinction

The failure is not that the relevance scorer is *wrong*. It is that the scorer's output is a *rank* consumed as a *quantity*. A learned relevance score `s_i ∈ [0,1]` for sub-agent `i` is calibrated only up to monotonic ordering within the batch it was computed on. When an orchestrator converts those scores into token budgets via normalization — `b_i = B · s_i / Σ s_j` — it silently promotes a within-batch ordinal into a cross-batch cardinal. Two consequences follow, and only the second is operationally dangerous:

  1. **Scale drift:** the same chunk, scored against a fresh query in a new batch, receives a different absolute score because the scorer's softmax is batch-relative. The *allocation* changes even when the *content* is identical.
  2. **Provenance staleness:** the scores were computed against a query or sub-task description that has since been revised by upstream reasoning (a plan edit, a tool result, a peer sub-agent's correction). The budget is now allocating context to answer a question the sub-agent is no longer asking.

The invariant that must hold, and that learned scorers do not natively provide, is: **a budget allocation is valid only if every score in the normalizing sum was computed against the sub-agent's current task descriptor, within a bounded staleness horizon, at a common scale.** Violate any of the three conjuncts and the proportional split is meaningless — not merely noisy.

What Was Observed

An orchestrator decomposed a research task into five sub-agents (`S1..S5`). At `t0` it scored 340 candidate chunks against the *original* plan and allocated a 96k-token budget: `S1: 31k, S2: 27k, S3: 18k, S4: 12k, S5: 8k`. The scores summed to 4.1 and normalized cleanly.

At `t1`, `S1` returned a tool result that invalidated the premise of `S2` and `S4`: their task descriptors were rewritten by the planner from "enumerate X" to "reconcile X against Y." The orchestrator re-scored *only* `S2` and `S4` (the changed agents) against their new descriptors, obtaining scores of 0.91 and 0.88 — high, because the new tasks were sharply defined and matched many chunks. It then re-normalized the full vector `[0.62, 0.91, 0.55, 0.88, 0.40]` and reallocated: `S2: 26k, S4: 25k`. `S1` and `S3` were *not* re-scored, but their budgets still shifted because the denominator changed. `S4` gained 13k tokens; `S1` lost 6k.

The 6k tokens `S1` lost were the tail of its evidence set — the chunks ranked 40–52, which the original scorer had rated 0.31–0.38. `S1` had already begun generating with those chunks in context. On the reallocation pass the orchestrator evicted them mid-generation, and `S1`'s next tool call referenced a chunk ID no longer in its window. The call returned a retrieval miss, `S1` re-fetched, and the re-fetched chunk arrived with different surrounding context (top-k is not stable across calls when the index has been written to by `S4` in the interim). `S1`'s final output cited a fact that was in the evicted chunk but contradicted the re-fetched version. The contradiction was not flagged because the verifier sub-agent had been allocated budget from the *same* stale vector and never received the original chunk either.

The trace, condensed:

t0  scores(orig_desc, 340 chunks) -> [0.62,0.58,0.55,0.44,0.40]  sum=2.59
    alloc -> [31k, 27k, 18k, 12k, 8k]   (B=96k)
t1  S1 tool_result invalidates S2,S4 descriptors
    re-score(S2,S4 only) -> 0.91, 0.88
    vector = [0.62, 0.91, 0.55, 0.88, 0.40]  sum=3.36   <-- mixed-provenance sum
    alloc -> [17k, 26k, 15k, 25k, 11k]  (note S1 31k->17k, never re-scored)
t1+ S1 generating; window evicted chunks 40..52 (score 0.31..0.38)
    S1 emits tool_call(chunk_id=0x4a2) -> miss
    re-fetch(0x4a2) -> different neighbors (S4 wrote to index at t1)
    S1 output cites contradictory fact; verifier blind (same stale vector)

The critical observation: **`S1`'s budget changed without `S1`'s score changing.** The orchestrator's reallocation logic treated the score vector as a closed set, but it had been mutated in two coordinates only. Proportional normalization is a global operation; partial re-scoring makes it a global operation over a mixed-provenance vector.

Condition of Validity

A proportional budget split `b_i = B · s_i / Σ s_j` is valid only when all of the following hold simultaneously:

The last condition is the one most often omitted. It follows from a simple fact about LLM execution: a sub-agent's context window is not a passive buffer. Once generation has begun, every token in the window has been *read* by the model's attention, and evicting a token retroactively invalidates the model's prior tokens-of-thought that depended on it. The model does not re-derive; it continues. Eviction mid-generation is not a budget adjustment, it is a silent context corruption.

Decision Boundary

The orchestrator must choose between two strategies at the moment a descriptor changes, and the choice is forced by whether any sub-agent is running:

| Condition | Strategy | Rationale | |---|---|---| | No sub-agent running; all descriptors stable | Full re-score, full re-normalize | Cheap, exact, common scale preserved | | Descriptor changed; affected sub-agents not yet started | Re-score affected only; **do not re-normalize the full vector** — instead allocate the changed agents from a reserved pool, leaving untouched agents' budgets fixed | Avoids the mixed-provenance sum; untouched agents' scores remain valid for their own budgets | | Descriptor changed; affected sub-agent already running | **Freeze** its budget at current allocation; re-score and reallocate only unstarted agents from the remaining pool | Mid-execution subtraction corrupts context; only addition is safe | | Scorer version changed mid-task | Treat all prior scores as void; re-score all, or freeze all running agents and re-score only unstarted | Cross-version scores are not on a common scale |

The boundary is sharp: **the instant the first sub-agent begins generation, the score vector ceases to be a freely re-normalizable object and becomes a set of committed allocations plus a residual pool.** The orchestrator's allocator must track this state transition explicitly. A scorer that returns scores without a provenance tag (descriptor hash, scorer version, batch ID) cannot support this decision and must not be used for proportional allocation across a live multi-agent run.

Operational Effect

When the invariant is violated, the observable symptom is not a crash. It is a *silent contradiction*: a sub-agent produces output that is internally consistent but inconsistent with a peer's output, and the verifier — allocated from the same stale vector — lacks the context to detect it. The contradiction surfaces downstream, often at final synthesis, where it is misattributed to a reasoning error rather than a budget-allocation error. This misattribution is the operational cost: debuggers chase the model's reasoning when the fault is in the orchestrator's arithmetic.

The guardrail is a provenance-carrying score object and an allocator that refuses to normalize across mixed provenance. The score must carry `(descriptor_hash, scorer_version, batch_id, step_index)`. The allocator must assert that all scores in a normalization share the same `scorer_version` and that each `descriptor_hash` matches the sub-agent's current binding; on mismatch it must fall back to the reserved-pool strategy rather than the proportional split. And it must treat any sub-agent with `state == RUNNING` as having a budget floor equal to its current allocation, regardless of new scores.

Guardrail Implementation

The following allocator enforces the invariant. It raises on the two conditions that, in the observed trace, produced silent corruption: mixed-provenance normalization and mid-execution budget subtraction.

import hashlib
from dataclasses import dataclass, field
from enum import Enum


class BudgetInvariantError(RuntimeError):
    """Raised when a proportional budget split would violate score provenance
    or evict context from a running sub-agent."""
    pass


class AgentState(Enum):
    PENDING = "pending"
    RUNNING = "running"
    DONE = "done"


@dataclass(frozen=True)
class ScoredAgent:
    agent_id: str
    score: float
    descriptor_hash: str      # hash of the task descriptor the score was computed against
    scorer_version: str
    batch_id: str
    step_index: int           # planner step at which the score was computed


@dataclass
class AgentSlot:
    agent_id: str
    state: AgentState = AgentState.PENDING
    current_budget: int = 0
    descriptor_hash: str = ""


def _h(descriptor: str) -> str:
    return hashlib.sha256(descriptor.encode()).hexdigest()[:16]


def allocate(
    total_budget: int,
    scores: list[ScoredAgent],
    slots: dict[str, AgentSlot],
    current_step: int,
    staleness_horizon: int = 0,
) -> dict[str, int]:
    """Proportional allocation with provenance and mid-execution guards.

    Returns a mapping agent_id -> new budget. Running agents are never
    reduced below their current_budget.
    """
    if not scores:
        raise BudgetInvariantError("empty score vector; cannot normalize")

    # Guard 1: common scorer version across the normalizing sum.
    versions = {s.scorer_version for s in scores}
    if len(versions) > 1:
        raise BudgetInvariantError(
            f"mixed scorer versions in normalization: {sorted(versions)}; "
            f"cross-version scores are not summable"
        )

    # Guard 2: descriptor provenance — every score must match the slot's
    # current descriptor binding.
    for s in scores:
        slot = slots.get(s.agent_id)
        if slot is None:
            raise BudgetInvariantError(f"score for unknown agent {s.agent_id}")
        if s.descriptor_hash != slot.descriptor_hash:
            raise BudgetInvariantError(
                f"stale score for {s.agent_id}: scored against "
                f"{s.descriptor_hash}, slot bound to {slot.descriptor_hash}"
            )

    # Guard 3: staleness horizon — scores must be from the current step
    # (or within the declared horizon).
    for s in scores:
        if current_step - s.step_index > staleness_horizon:
            raise BudgetInvariantError(
                f"score for {s.agent_id} is {current_step - s.step_index} steps "
                f"stale, horizon is {staleness_horizon}"
            )

    # Guard 4: running agents are committed; only the residual pool is
    # divisible. This is the guard whose absence caused the S1 eviction.
    committed = {
        aid: slot.current_budget
        for aid, slot in slots.items()
        if slot.state is AgentState.RUNNING
    }
    committed_total = sum(committed.values())
    if committed_total > total_budget:
        raise BudgetInvariantError(
            f"committed budgets ({committed_total}) exceed total ({total_budget}); "
            f"cannot honor running agents without eviction"
        )

    residual = total_budget - committed_total
    pending = [s for s in scores if s.agent_id not in committed]
    if not pending:
        return dict(committed)

    total_score = sum(s.score for s in pending)
    if total_score <= 0:
        raise BudgetInvariantError("non-positive score mass in residual pool")

    result = dict(committed)
    for s in pending:
        share = int(residual * (s.score / total_score))
        # Running agents (none here) would be floored; pending agents get share.
        prev = slots[s.agent_id].current_budget
        if slots[s.agent_id].state is AgentState.RUNNING and share < prev:
            raise BudgetInvariantError(
                f"allocation would evict {prev - share} tokens from running "
                f"agent {s.agent_id}; mid-execution subtraction is prohibited"
            )
        result[s.agent_id] = share
    return result


def apply_reallocation(
    total_budget: int,
    scores: list[ScoredAgent],
    slots: dict[str, AgentSlot],
    current_step: int,
) -> dict[str, int]:
    """Entry point used by the orchestrator on every planner edit."""
    try:
        new_budgets = allocate(total_budget, scores, slots, current_step)
    except BudgetInvariantError as e:
        # Fallback: freeze running agents, re-score only pending, allocate
        # residual pool. Never re-normalize the full mixed vector.
        raise BudgetInvariantError(
            f"proportional reallocation refused: {e}. "
            f"Fall back to reserved-pool allocation for pending agents only."
        ) from e

    # Commit and detect any reduction against a running agent.
    for aid, slot in slots.items():
        if slot.state is AgentState.RUNNING and new_budgets.get(aid, 0) < slot.current_budget:
            raise BudgetInvariantError(
                f"post-hoc reduction of running agent {aid}: "
                f"{slot.current_budget} -> {new_budgets.get(aid, 0)}"
            )
    for aid, b in new_budgets.items():
        slots[aid].current_budget = b
    return new_budgets