What happens when an instance wins a contract-net bid and then loses its bidder identity during role reassignment

**Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems that allocate work via contract-net protocol (CNP) bidding where a manager agent awards a task to a bidder, then later reassigns roles or re-broadcasts the task while the original award is still in flight. Does not apply to single-agent tool loops or to static role assignment without bidding.

Core Distinction

The failure is not "a bidder crashed." The failure is that **the award and the role assignment are two separate state transitions with no shared transaction boundary**, so a manager can commit an award to bidder identity `B₁` while the role-reassignment path commits the same logical task to `B₂`. The non-obvious part: contract-net protocol is *optimistic and stateless at the bid layer* — a bid is a proposal, not a reservation. Managers routinely treat "award sent" as "slot filled," but the award message carries a `bid_id` that is only meaningful relative to the bidder's *ephemeral* bid record. When role reassignment evicts or re-keys that record (because the agent instance is recycled, its context window was compacted, or its role label changed), the award arrives at an instance that has no memory of having bid, or arrives at a *different* instance now holding the same role label. The bidder cannot distinguish "I won" from "I am receiving a stale award for a bid I never made."

What Was Observed

A three-tier swarm: one manager `M`, four workers `W1..W4`, task `T` requiring a single executor. Sequence:

  1. `M` broadcasts `CFP(T, deadline=d)`. Each `Wᵢ` emits `Bid(bid_idᵢ, cost, eta, capability_vector)`.
  2. `W2` wins; `M` commits `award(T → W2, bid_id=0x7f)`. This is a **logical reservation** recorded only in `M`'s task ledger and in `W2`'s short-term bid cache.
  3. Before `W2` acknowledges, the orchestrator triggers a **role reassignment** (e.g., `W2`'s health probe flapped, or a capacity rebalance demoted it). The reassignment path re-keys `W2`'s role label from `executor-2` to `standby-2` and, critically, **drops the bid cache as part of the role transition** — because the cache was scoped to the old role, not to the agent instance.
  4. `M`'s award retry (or the reassignment's own re-broadcast) delivers `award(T, bid_id=0x7f)` to `W2`. `W2` has no `bid_id=0x7f` in cache. Two behaviors observed, both wrong:

The observable signature is **divergent task ledgers**: `M`'s ledger shows one award; the worker pool shows two executions, or zero, depending on which branch the stale instance took.

Condition of Validity

This boundary only bites when **all** of the following hold:

If awards are synchronous and acknowledged before any reassignment can fire, or if bid records are keyed to an immutable instance ID that is *carried across* role changes, the failure does not occur. The invariant that is missing: **award validity must be a function of the bid content, not of the bidder's current role label.**

Decision Boundary

The manager must choose, at award-commit time, between two policies, and the choice is not free:

The failure mode above is what happens when a system *claims* bind-to-instance (it checks `bid_id`) but *implements* bind-to-role (the bid cache is role-scoped). The decision boundary is: **you cannot have role reassignment that is cheaper than award resolution unless awards are re-derivable.** Pick one; the hybrid is the bug.

Operational Effect

Concretely, the system exhibits **phantom awards** (manager believes `T` is assigned; no live instance holds the bid) and **duplicate awards** (two instances execute `T` because the stale one accepted a syntactically valid award). The duplicate case is the dangerous one: it produces non-idempotent side effects that no amount of retry logic at the manager can undo, because the manager never knew two executions were possible. The guardrail is a **bid-record pin with an epoch tag**: every award carries `(bid_id, bidder_epoch)`, and the bidder rejects any award whose `bidder_epoch` does not match its current epoch *unless* the award is explicitly marked re-derivable. Combined with an idempotency key on `T`'s side effects, this bounds the blast radius to a bounded retry rather than a silent double-write.

import hashlib
from dataclasses import dataclass, field
from typing import Dict, Optional


class PhantomAwardError(RuntimeError):
    """Raised when an award cannot be matched to a live, epoch-consistent bid."""
    pass


@dataclass
class Bid:
    bid_id: str
    bidder_id: str
    bidder_epoch: int
    capability: frozenset
    cost: float


@dataclass
class Award:
    task_id: str
    bid_id: str
    bidder_epoch: int
    re_derivable: bool = False


@dataclass
class Bidder:
    instance_id: str
    epoch: int
    role: str
    capability: frozenset
    bids: Dict[str, Bid] = field(default_factory=dict)
    pinned: Dict[str, Bid] = field(default_factory=dict)

    def record_bid(self, bid: Bid) -> None:
        self.bids[bid.bid_id] = bid

    def reassign_role(self, new_role: str) -> None:
        # Role change increments epoch and evicts unpinned bids only.
        self.role = new_role
        self.epoch += 1
        self.bids = {k: v for k, v in self.bids.items() if k in self.pinned}

    def pin_for_award(self, bid_id: str) -> None:
        if bid_id not in self.bids:
            raise PhantomAwardError(f"cannot pin unknown bid {bid_id}")
        self.pinned[bid_id] = self.bids[bid_id]

    def accept_award(self, award: Award) -> str:
        bid = self.pinned.get(award.bid_id) or self.bids.get(award.bid_id)
        if bid is None:
            if award.re_derivable and self.capability >= bid_capability_floor(award):
                return f"re-derived:{award.task_id}"
            raise PhantomAwardError(
                f"award {award.bid_id} for task {award.task_id} has no live bid "
                f"on {self.instance_id} (epoch={self.epoch}, role={self.role})"
            )
        if bid.bidder_epoch != award.bidder_epoch and not award.re_derivable:
            raise PhantomAwardError(
                f"epoch mismatch: award expects {award.bidder_epoch}, "
                f"bidder at {bid.bidder_epoch}"
            )
        # Idempotency key bounds duplicate side effects.
        key = hashlib.sha256(
            f"{award.task_id}:{award.bid_id}".encode()
        ).hexdigest()[:16]
        return f"executing:{award.task_id}:idem={key}"


def bid_capability_floor(award: Award) -> frozenset:
    # In production this is looked up from the task spec, not the award.
    return frozenset()


def manager_award(bidder: Bidder, task_id: str, bid_id: str, re_derivable: bool = False) -> str:
    bidder.pin_for_award(bid_id)  # pins before reassignment can fire
    award = Award(
        task_id=task_id,
        bid_id=bid_id,
        bidder_epoch=bidder.pinned[bid_id].bidder_epoch,
        re_derivable=re_derivable,
    )
    return bidder.accept_award(award)


# --- Trace of the failure and its bounding guardrail ---
w2 = Bidder("W2", epoch=1, role="executor-2", capability=frozenset({"write"}))
w2.record_bid(Bid("0x7f", "W2", 1, frozenset({"write"}), cost=3.0))

manager_award(w2, "T", "0x7f")          # pins 0x7f, award accepted
w2.reassign_role("standby-2")            # epoch -> 2; pinned bid survives
# Retry of the same award still resolves because the pin outlives the role change:
manager_award(w2, "T", "0x7f")

# Without the pin, the same sequence raises:
w3 = Bidder("W3", epoch=1, role="executor-3", capability=frozenset({"write"}))
w3.record_bid(Bid("0x9a", "W3", 1, frozenset({"write"}), cost=2.0))
w3.reassign_role("standby-3")            # unpinned bid evicted
try:
    w3.accept_award(Award("T", "0x9a", 1, re_derivable=False))
except PhantomAwardError as e:
    raise PhantomAwardError(
        "phantom award: manager committed to a bid the bidder no longer holds"
    ) from e