AI Wiki中文/EN

Cooperative agents: sharing work through announcements, bids and contracts

协作智能体

Use the contract net protocol to allocate tasks among agents with a shared objective, compute marginal-cost bids by hand, and see why single-task re-contracting can stall where bundle contracts reach the optimum.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Three vans, six deliveries, one shared bill

A small company runs three delivery vans parked at different depots along one road. Six parcels must be delivered today, and the company pays for all the driving. Each van’s driver knows where their own van is and what it already has to carry, but no one has a dispatcher’s screen. How should the parcels be shared out?

This is a problem for cooperative agents: several decision-makers with different local information but one common objective, here the total distance driven. Nobody gains from hiding information or winning parcels for themselves; the difficulty is purely one of coordination. Shoham and Leyton-Brown separate this kind of distributed problem solving from strategic settings: the global goal can be read as a shared goal or as the goal of one designer who built all the agents. Cooperative distributed problem solving

A classical answer is to let agents negotiate. Reid Smith’s contract net protocol, published in IEEE Transactions on Computers in December 1980, turns task allocation into a market-like exchange of messages: whoever has a task announces it, agents able to do it bid, and the announcer awards a contract. Contract net protocol This article uses that protocol as its core mechanism, computes what it does on a small example, and shows where greedy contracting leaves cost on the table. Auctions with self-interested bidders, negotiation strategy and learned cooperation (for example centralized training with decentralized execution) are separate topics.

From a shared objective to a negotiation protocol

Let N be the agents and T the tasks. An allocation σ gives each agent i a set T_i(σ), and c_i(S) is what it costs agent i to perform set S. In a cooperative setting the objective is the total cost, and the natural bid for one more task t is the marginal cost:

C(σ)=∑i∈Nci(Ti(σ)),bi(t)=ci(Ti∪{t})−ci(Ti)C(\sigma)=\sum_{i\in N} c_i\big(T_i(\sigma)\big),\qquad b_i(t)=c_i\big(T_i\cup\{t\}\big)-c_i(T_i)

Shoham and Leyton-Brown describe exactly this marginal-cost version: each agent bids its additional cost for adding the task to its current set, the lowest bidder gets the task, and the process repeats. They also state three results that shape everything below. Some sequence of contracts always reaches an optimal allocation. With only simple contracts that move one task from one agent to another, reaching the optimum may in general require “money-losing” contracts along the way; read in cooperative terms, these are steps that do not lower the total cost. Richer contracts—bundles of tasks (“cluster contracts”), exchanges between two agents (“swap contracts”) or simultaneous transfers among many agents—can avoid such steps. The process can also have an anytime property: if it is interrupted before reaching the optimum, it may already have improved substantially on the initial allocation. Marginal-cost contracting and contract types

Smith’s paper explains why one would distribute the decision in the first place. In distributed problem solving, no single knowledge source has enough information to solve the whole problem, and there is neither global control nor global data storage. Agents with tasks must find suitable idle agents—Smith’s “connection problem”, which has two aspects: balancing load (resource allocation) and choosing the right tasks and knowledge sources (focus). Distributed problem solving and the connection problem Negotiation, in his sense, has four features: it is local, information flows both ways, each party evaluates offers from its own perspective, and agreement comes from mutual selection.

The protocol’s messages carry that negotiation:

MessageSenderMain content in Smith’s specification
Task announcementManagerTask abstraction, eligibility specification, bid specification, expiration time
BidPotential contractorNode abstraction: the bidder’s relevant capabilities, in the form requested
AwardManagerTask specification needed to start work
Report / information / terminationEitherInterim or final results, mid-contract messages, cancellation of a contract and its subcontracts

Roles are not fixed in advance. Any node can be a manager for one task and a contractor for another, and a contractor can split its task and subcontract parts, so a control hierarchy grows and shrinks with the problem. Announcements can be broadcast to all nodes, to a subset, or to one node (“focused addressing”), and the eligibility specification lists criteria a node must meet before bidding, which prunes clearly unacceptable bids and reduces message traffic. Message types and roles

Smith is explicit that many choices are tentative engineering trade-offs. In his CNET implementation bids are binding and only idle nodes bid, one bid per opportunity, so a node can receive several awards and must queue them; letting nodes refuse awards would cost extra acknowledgement messages. A manager may award as soon as a satisfactory bid arrives instead of waiting for the deadline. If no bids arrive, the manager cannot tell whether every node is busy, the task was ranked too low, or no node is capable; “immediate response bids” let nodes answer BUSY, INELIGIBLE or LOW RANKING to resolve that ambiguity. Negotiation trade-offs and immediate response bids

For one task with |N| potential contractors, a broadcast announcement, a bid from everyone and a single award cost

Mtask=1+∣N∣+1M_{\mathrm{task}}=1+|N|+1

messages if a broadcast counts once. Focused addressing and eligibility rules reduce the middle term; immediate-response bids increase it but buy diagnostic information.

The cooperative assumption carries weight. Shoham and Leyton-Brown stress that in this setting agents do not deviate from the prescribed bidding rules for personal gain, so the auction-like procedures make no claim about adversarial situations. The cooperative assumption If a van driver were paid per parcel and could exaggerate costs to shed work, the same messages would need mechanism design to stay truthful.

Modern language-model agents revisit cooperation with natural-language messages instead of slot-structured ones. CAMEL’s role-playing framework assigns one model the role of an AI user who issues instructions and another the role of an AI assistant who answers; the message history M_t grows by one instruction–solution pair per turn. Fixed “inception prompts” at the start specify roles, format and an end-of-task token, and an optional critic can choose among proposals. The authors report that summarized role-play solutions were preferred over single-shot gpt-3.5-turbo solutions in their human evaluation (76.3% to 10.4%, 13.3% draws, from 453 responses) and in a GPT-4 evaluation; these are their reported results on their tasks, not measurements made here. They also document failure modes absent from a slot protocol: role flipping, repeated instructions, empty promises and endless polite loops. Role-playing and its failure modes

Contract net on a line, checked against the optimum

The program places three depots and six tasks at integer positions on a road. A van’s cost for a set of tasks is a round trip covering its depot and all assigned points, twice the covered span. Contract net announces tasks in index order and awards each to the lowest marginal-cost bidder, ties to the lower index. Two repair phases then re-contract while some move strictly lowers total cost: one allows only single-task transfers, the other also allows a bundle of two tasks held by one agent to move together, a simple cluster contract. Exhaustive search over all 3⁶=729 allocations gives the optimum. Everything is an original synthetic instance with scripted agents.

"""Original contract-net toy: three cooperative scripted agents share six delivery tasks.
Agents and tasks lie on a line; no market data, learning model, network or LLM is used."""
import itertools
import random
import statistics

AGENTS, TASKS = 3, 6


def tour_cost(base, points):
    """Leave base, visit every point on a line and return: twice the covered span."""
    if not points:
        return 0
    return 2 * (max(base, *points) - min(base, *points))


def total_cost(bases, tasks, owner):
    return sum(tour_cost(bases[i], [tasks[t] for t in range(len(tasks)) if owner[t] == i]) for i in range(len(bases)))


def contract_net(bases, tasks):
    """Announce tasks in index order; every agent bids its marginal cost; lowest bid wins."""
    owner, messages = [None] * len(tasks), 0
    for t in range(len(tasks)):
        bids = []
        for i in range(len(bases)):
            mine = [tasks[s] for s in range(len(tasks)) if owner[s] == i]
            bids.append((tour_cost(bases[i], mine + [tasks[t]]) - tour_cost(bases[i], mine), i))
        owner[t] = min(bids)[1]
        messages += 1 + len(bases) + 1  # one broadcast announcement, all bids, one award
    return owner, messages


def improve(bases, tasks, owner, max_bundle):
    """Re-contract while moving one bundle of up to max_bundle tasks, all held by one agent,
    to another agent strictly lowers total cost. Returns the allocation and contracts signed."""
    owner, contracts = owner[:], 0
    while True:
        current, best = total_cost(bases, tasks, owner), None
        for size in range(1, max_bundle + 1):
            for bundle in itertools.combinations(range(len(tasks)), size):
                if best is None and len({owner[t] for t in bundle}) == 1:
                    for i in range(len(bases)):
                        trial = [i if t in bundle else owner[t] for t in range(len(tasks))]
                        if i != owner[bundle[0]] and total_cost(bases, tasks, trial) < current:
                            best = trial
                            break
        if best is None:
            return owner, contracts
        owner, contracts = best, contracts + 1


def optimum(bases, tasks):
    return min(total_cost(bases, tasks, list(o)) for o in itertools.product(range(len(bases)), repeat=len(tasks)))


def instance(seed):
    rng = random.Random(seed)
    return [rng.randint(0, 20) for _ in range(AGENTS)], [rng.randint(0, 20) for _ in range(TASKS)]


if __name__ == '__main__':
    bases, tasks = [8, 1, 16], [15, 11, 13, 1, 4, 5]
    owner, messages = contract_net(bases, tasks)
    print('worked instance bases', bases, 'tasks', tasks)
    print('contract net owner', owner, 'cost', total_cost(bases, tasks, owner), 'messages', messages)
    print('optimum cost', optimum(bases, tasks))
    for size in (1, 2):
        better, contracts = improve(bases, tasks, owner, size)
        print(f'bundle size <= {size}: owner {better}, cost {total_cost(bases, tasks, better)}, contracts {contracts}')
    print('move task 1 alone', total_cost(bases, tasks, [2, 2, 0, 1, 1, 1]),
          'move task 2 alone', total_cost(bases, tasks, [2, 0, 2, 1, 1, 1]),
          'then task 1', total_cost(bases, tasks, [2, 2, 2, 1, 1, 1]))
    stats = {'contract_net': [], 'single_transfers': [], 'bundles_up_to_two': []}
    optimal = {key: 0 for key in stats}
    extra = {'single_transfers': [], 'bundles_up_to_two': []}
    for seed in range(300):
        bases, tasks = instance(seed)
        best = optimum(bases, tasks)
        greedy, _ = contract_net(bases, tasks)
        results = {'contract_net': (greedy, 0)}
        results['single_transfers'] = improve(bases, tasks, greedy, 1)
        results['bundles_up_to_two'] = improve(bases, tasks, greedy, 2)
        for key, (owner, contracts) in results.items():
            cost = total_cost(bases, tasks, owner)
            stats[key].append(cost - best)
            optimal[key] += cost == best
            if key in extra:
                extra[key].append(contracts)
    for key in stats:
        print(f'{key}: optimal {optimal[key]}/300, mean excess {statistics.mean(stats[key]):.3f}, '
              f'max excess {max(stats[key])}')
    for key in extra:
        print(f'{key}: mean extra contracts {statistics.mean(extra[key]):.3f}, max {max(extra[key])}')
    print('messages per task with 3 agents', 1 + AGENTS + 1)
Recorded output
worked instance bases [8, 1, 16] tasks [15, 11, 13, 1, 4, 5]
contract net owner [2, 0, 0, 1, 1, 1] cost 20 messages 30
optimum cost 18
bundle size <= 1: owner [2, 0, 0, 1, 1, 1], cost 20, contracts 0
bundle size <= 2: owner [2, 2, 2, 1, 1, 1], cost 18, contracts 1
move task 1 alone 28 move task 2 alone 20 then task 1 18
contract_net: optimal 278/300, mean excess 0.213, max excess 6
single_transfers: optimal 285/300, mean excess 0.140, max excess 6
bundles_up_to_two: optimal 295/300, mean excess 0.047, max excess 4
single_transfers: mean extra contracts 0.027, max 2
bundles_up_to_two: mean extra contracts 0.060, max 2
messages per task with 3 agents 5

Follow the worked instance by hand. Depots are at 8, 1 and 16; tasks are at 15, 11, 13, 1, 4 and 5. Task 0 at 15 goes to the van at 16 for a marginal cost of 2. Task 1 at 11 costs the van at 8 an extra 6, the van at 1 an extra 20 and the van at 16 an extra 8 (its span grows from 15–16 to 11–16), so the van at 8 wins. Task 2 at 13 costs the van at 8 another 4 (its span grows from 8–11 to 8–13), the same as the van at 16, and the tie goes to the lower index. The last three tasks go to the van at 1. Total cost: 10+8+2=20, using 6×5=30 messages.

The optimum is 18: the van at 16 should take all three tasks at 11, 13 and 15 and the van at 8 should stay home. Single transfers cannot get there. Moving task 1 alone to the van at 16 raises the cost to 28, because the van at 8 still drives to 13. Moving task 2 alone leaves the cost at exactly 20—a plateau, not an improvement, so a rule that accepts only strict improvements stops. Only after that sideways step would moving task 1 reach 18. A bundle contract that moves tasks 1 and 2 together lowers the cost from 20 to 18 in one step. This is a concrete instance of the textbook’s point that single-task contracting may need non-improving steps that richer contracts avoid.

Across 300 random instances, pure contract net is optimal in 278 cases with a mean excess of 0.213 distance units over the optimum and a worst excess of 6. Single-task re-contracting raises that to 285 optimal cases (mean excess 0.140) and signs on average 0.027 extra contracts. Allowing two-task bundles gives 295 optimal cases, mean excess 0.047 and worst excess 4, with 0.060 extra contracts on average. Five instances still need larger bundles or several agents moving at once.

The greedy phase evaluates |N| bids per task, each in O(|T|) time here, so it is O(|T|²|N|). One sweep of bundle moves of size up to k checks O(|T|^k |N|) candidates; the exhaustive optimum costs |N|^|T| evaluations and is only feasible because the instance is tiny.

Where cooperative contracting breaks down

The results depend on announcement order and tie-breaking. Announcing tasks in a different order changes which agent “anchors” a region first, and nothing in the protocol itself guarantees good orders. Real deployments also face deadlines, capacity limits, travel times that are not a straight line, and tasks that appear while others are in progress.

The experiment assumes perfect cost knowledge and reliable, instantaneous messages. In Smith’s protocol late bids may produce suboptimal choices rather than errors, but lost awards or crashed contractors need the report and termination machinery to be used carefully. Binding bids from busy nodes can also overload a node that receives several awards at once.

Cooperation is an assumption about incentives, not a property of the protocol. If agents represent different owners, marginal-cost bids can be inflated, and the allocation can be gamed. Language-model “cooperative” agents add another layer: they can misunderstand roles, repeat themselves or politely loop, and evaluations by another model can share that model’s biases. A cooperative design should still be compared with a central planner whenever one is feasible.

Exercises

  1. Why does Smith describe contracting as solving a “connection problem”, and which two aspects does it have?

    Answer: Nodes with tasks must find suitable nodes to perform them, and idle nodes must find suitable tasks; that matching is the connection problem. Its two aspects are resource allocation, which balances computational load across nodes, and focus, which selects the right tasks and knowledge sources so that effort is not wasted on unpromising work.

  2. A depot is at 0 and its van already serves points 2 and 6. What marginal cost does it bid for a task at 9, and for a task at 4?

    Answer: The current cost is 2×(6−0)=12. Adding 9 gives 2×(9−0)=18, so the bid is 6. Adding 4 leaves the span 0–6 unchanged, so the bid is 0. Marginal-cost bids reward tasks that fit inside routes already being driven.

  3. In the worked instance, a single transfer of task 2 leaves the total cost at 20. Why does a rule that accepts only strict improvements stop there, and give two ways to escape?

    Answer: The move does not lower the total, so it is rejected and no other single transfer helps; the allocation is a local optimum for single transfers. One escape is to accept non-worsening moves, which allows task 2 and then task 1 to move for a total of 18. The other is a bundle contract that moves tasks 1 and 2 together in one improving step.

  4. Two departments in one company use contract net to share computing jobs, but each department’s budget is charged for the jobs it accepts. What changes, and what would you check before reusing the protocol?

    Answer: Interests now diverge: a department may bid high to avoid work or low to capture budget, so marginal-cost bids are no longer trustworthy. Before reuse, check whether bids can be verified, whether payments make truthful bidding a good strategy (a mechanism-design question), and whether a central scheduler with audited costs would be simpler.

Reading the sources

Smith’s 1980 paper is short and concrete; its distributed-sensing example and its frank discussion of negotiation trade-offs remain good reading for anyone designing delegation between software agents. The Contract Net Protocol Shoham and Leyton-Brown’s section 2.3 connects contract nets to auction-style optimization and explains why the cooperative assumption lets them set aside game theory. Multiagent Systems, section 2.3 CAMEL is a 2023 example of cooperation among language-model agents, with documented failure modes. CAMEL

Open questions include how to choose bundle sizes that are rich enough without exploding the search, how to keep contracting robust when agents fail mid-task, and how to evaluate cooperative LLM agents against strong single-agent baselines with independent judges.

Make a prediction, then check

A depot is at 0 and its van already serves points 2 and 6 (cost 12). What marginal-cost bid does it make for a new task at 9?

Choose one answer

Learning objectives

  • Describe contract-net announcements, bids, awards and reports, and hand-compute marginal-cost bids and message counts under a shared objective.
  • Explain why single-task re-contracting can stall at a local optimum, compare bundle contracts with the exhaustive optimum, and state when the cooperative assumption fails.

Prerequisites & connections

Explore related knowledge →

References

  1. The Contract Net Protocol: High-Level Communication and Control in a Distributed Problem Solver — scoped course-hosted copy
    Reid G. Smith · 1980
  2. Multiagent Systems: Algorithmic, Game-Theoretic, and Logical Foundations — scoped free PDF, revision 1.1
    Yoav Shoham; Kevin Leyton-Brown · 2009
  3. CAMEL: Communicative Agents for “Mind” Exploration of Large Language Model Society — scoped arXiv v2
    Guohao Li; Hasan Abed Al Kader Hammoud; Hani Itani; Dmitrii Khizbullin; Bernard Ghanem · 2023

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Claude · 2026-12-02 · Independent AI check (Claude subagent, not the author; not a human or expert review). Ran example.py with python3 (0.4 s) and diffed it against example.stdout.txt (identical); confirmed byte-identical code blocks and identical display equations in both languages. Re-derived the whole worked instance by hand (bids 2; 6/20/8; tie 4/4 to the lower index; 2/14, 6/8, 2/6 for the last three tasks; total 20; single moves 28 and 20; optimum 18; 30 messages), the message formula and the exercise answers. Re-read the sources myself via pdftotext: Smith 1980 pp. 1104–1108 (course-hosted PDF), Shoham–Leyton-Brown §2.3.1 pp. 28–30, and CAMEL v2 pp. 8–9 (Section 5.1, Table 1). Compared zh and en section by section and checked data.json IDs. Did not read Smith pp. 1109–1113 or compare with IEEE Xplore, and did not render the MDX.

  • Code output consistent; every hand value of the worked instance re-derived correctly.
  • Smith's connection problem, four negotiation components, messages, trade-offs and immediate-response bids are supported by the text.
  • CAMEL figures (453 responses, 76.3%/10.4%/13.3%) match Table 1 and are presented as the authors' reported results.
  • The book's wording on the anytime property and money-losing contracts is weaker than the draft; the article was softened to match.

Source locations checked:

  • The Contract Net Protocol: High-Level Communication and Control in a Distributed Problem Solver — scoped course-hosted copy · UCF course copy via pdftotext, journal pages 1104–1108: abstract and index terms; I Introduction (distributed problem solving: no global control or data; high-level protocol); II Connection and contract negotiation (connection problem = resource allocation + focus; four negotiation components; manager/contractor roles; subcontracting hierarchy; DCS comparison); III Example (DSS signal task, Figs. 1–3); IV.A.1–6 (announcement slots and addressing modes; common internode language; announcement processing; bidding by idle nodes; bid processing with immediate award; expiry options; award, report, information, termination; negotiation trade-offs: binding bids, multiple awards queued, refusal cost); IV.B.1 start (immediate response bids BUSY/INELIGIBLE/LOW RANKING). NOT read: pp.1109–1113, appendices A–E, results; not checked against IEEE Xplore. Checker re-downloaded the same 10-page PDF and re-read pp. 1104–1108 via pdftotext (raw and layout) on 2026-12-02, confirming: no global control or data; connection problem with resource allocation and focus; four negotiation components incl. mutual selection; general/limited broadcast and point-to-point (focused addressing); eligibility specification reduces traffic; late bids at worst give a suboptimal contractor choice; immediate award on a satisfactory bid; report/information/termination messages (termination also ends subcontracts); tentative negotiation trade-offs (binding bids, queued multiple awards, refusal costs acknowledgements, one bid per opportunity, only idle nodes bid); BUSY/INELIGIBLE/LOW RANKING immediate-response bids.
  • Multiagent Systems: Algorithmic, Game-Theoretic, and Logical Foundations — scoped free PDF, revision 1.1 · Free PDF rev. 1.1 via pdftotext (533 PDF pages): contents; Introduction pp. xiii–xvi (e-commerce agent example; loose definition 'diverging information or diverging interests, or both'; chapter overview and blocks); ch.1 p.1 (cooperative distributed problem solving, central-designer remark, sensor networks); §2.3.1 pp.28–30 (contract nets as framework; marginal-cost bids; existence of optimal contract sequence; money-losing single-task contracts; cluster/swap/multiagent contracts; anytime; bidding/clearing/information rules; no claim for adversarial settings); §7.1.3 pp.202–204 (Chicken teaching example, descriptive vs prescriptive, self-play, no procedure optimal vs all opponents); §7.2 pp.206–210 (fictitious play rule, prior sensitivity, Matching Pennies table, Thms 7.2.2–7.2.5, anti-coordination miscorrelation, Shapley game non-convergence). NOT read: other chapters, ABT details, proofs. Note: another 015k writer registered this same PDF as mas-ch3-normal-form-scoped-015k for chapter 3; scopes differ. Checker re-read §2.3.1 pp. 28–30 via pdftotext on 2026-12-02. The book says the process 'can have' an anytime property and 'can achieve significant improvements' if interrupted; the article's earlier stronger wording ('no worse than the start') and its gloss of money-losing contracts as steps that 'temporarily raise cost' were softened to match.
  • CAMEL: Communicative Agents for “Mind” Exploration of Large Language Model Society — scoped arXiv v2 · arXiv v2 PDF via pdftotext: p.1 (abstract, v2 date 2 Nov 2023, NeurIPS 2023 footer), p.2 (challenges: role flipping, assistant repeating instructions, flake replies, infinite loop; contributions), p.5 (AI user/assistant roles, Eq. 1–4 message set M_t, critic-in-the-loop, inception prompting P_T/P_A/P_U), p.7 (flake responses, 'Next request', <CAMEL_TASK_DONE> end token and the thank-you loop), p.9 (Table 1: AI Society human eval 13.3% draw / 10.4% gpt-3.5 / 76.3% CAMEL from 453 responses; GPT-4 eval 4.0/23.0/73.0; Code GPT-4 eval 0/24/76), p.28 (Appendix G challenge examples). NOT read: other appendices, Misalignment dataset, HumanEval results, code. Checker re-read pp. 8–9 (Section 5.1, Table 1) via pdftotext on 2026-12-02: 100 sampled AI Society tasks, CAMEL conversation summarized by GPT-4 vs gpt-3.5-turbo single shot, 453 human responses, 76.3/10.4/13.3; the article presents these only as the authors' reported results.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.