Negotiation, Simulation and Agent Economies
Contract Net, OG-Narrator bargaining, Smallville memory, Theory of Mind tests, Shapley credit and second-price auctions.
- Concepts and terms
- Tasks and commands
- Annotated code
- Diagrams
- Defaults and numbers
- Troubleshooting
- Questions and tips
Contract Net task market#
Negotiation mechanisms#
- OG-Narrator
- a deterministic offer generator computes the price. The LLM only narrates.
- Offer generator
- Rubinstein bargaining, Zeuthen strategy or tit-for-tat over price.
- Rule
- let the LLM narrate. Do not let the LLM compute the offer.
- Structured proposal
- the LLM drafts it. Validate it against a schema before you send.
- CoT concealment
- winners compute strategy privately. The public channel shows the offer only.
- Persona manipulation
- a desperation persona gives about 20% more payoff.
Bargaining in code#
state = BargainState(buyer_max=buyer_max, seller_min=seller_min)og_narrator_bargain(state, rng, concession=0.35)buyer offerseller_response(state, rng, concession=0.3)seller countermove = max(1, int(concession * (state.seller_offer - prior)))candidate = min(candidate, state.buyer_max)never past own maxnaive_llm_bargain(state, rng)high variance, often outside ZOPAbench_deal_rate(buyer_fn, label, trials=1000)deal rate in percentwinner = max(feasible, key=lambda b: b.confidence / max(b.price, 1))Generative agent loop#
Memory retrieval#
top = retrieve_top_k(stream, query="party cafe", tick=4, k=3)recency = math.exp(-0.3 * (tick - m.ts))exponential decay by ageimportance = m.importance / 10.0self-rated 1 to 10relevance = 0.6 if any(w in m.content.lower() for w in query.lower().split()) else 0.1score = recency + importance + relevancesorted, keep [:k]a.reflect(tick)importance >= 6 in the last 5 ticksa.update_plan(tick)belief adds Plan(tick=5, where="HobbsCafe")action = a.act(tick)move when the plan tick arrivesTheory of Mind and coordination#
- Zeroth-order
- no model of others. The agent acts on its own observations only.
- First-order
- a model of each other agent's beliefs. "Alice believes X."
- Second-order
- recursive beliefs. "Alice believes that Bob believes X."
- ToM state
- the
other_modelsattribute. Keep it as{agent_id: belief_list}. - Riedl metrics
- identity-linked differentiation, goal-directed complementarity, higher-order synergy.
- Real signals
- complementarity over time, anticipation and correction by turn T+2.
- Demo
run_trial(n_agents, n_boxes, tom, seed, max_turns=10)counts duplications.
Economy mechanisms in code#
| Task | Code |
|---|---|
| Exact Shapley, small N | shapley_exact(value_fn, |
| Sampled Shapley | shapley_sampled(value_fn, |
| Truthful auction | second_price(bids) |
| Winner pays | payment = |
| Reputation store | Reputation(alpha= |
| Update after a task | rep.update(agent, |
| Route by reputation | weighted_choice(agents, |
Run the demos#
| Command | What it does |
|---|---|
python3 code/main.py in 16-16 | Naive LLM ~65-75% deals, OG-Narrator ~85-95% |
python3 code/main.py in 16-17 | 3 of 5 agents converge at the party |
python3 code/main.py in 16-18 | ToM duplicates ~5%, zeroth-order ~35% |
python3 code/main.py in 16-21 | Rep routing gives 10-20% quality gain |
Defaults in the lesson code#
| Setting | Default | Note |
|---|---|---|
max_rounds | 5 | Bargaining rounds per trial |
Buyer concession | 0.35 | Seller uses 0.3 |
Bargain trials | 1000 | ToM bench uses 200 |
Retrieval k | 3 | Top-k memories in the prompt |
| Reflection trigger | 150 | Sum of importance of unprocessed memories |
max_turns | 10 | ToM token-collection budget |
alpha | 0.95 | Reputation decay |
floor | 0.1 | Lowest reputation score |
Numbers to remember#
- OG-Narrator
- deal rate from 26.67% to 88.88%.
- Competition
- ~180k negotiations. Concealing agents won.
- Symmetric pairs
- inequitable outcomes on about 40% of scenarios.
- Smallville
- 25 agents. 24 had no knowledge of the party.
- Shapley cost
- N=3 has 6 permutations. N=10 has 3.6M.
- Shapley sampling
- 100-1000 orderings.
Failure modes#
| Symptom | Cause | Fix |
|---|---|---|
| Offers outside the ZOPA | LLM computes the price | Deterministic offer generator |
| Counterpart knows your limit | Reservation price in a visible trace | Separate private scratchpad |
| Agents enter closed stores | Spatial norm errors | Detect norm violations explicitly |
| Retrieval cost grows | Memory overflow | Summarize-and-prune, decay low importance |
| Invented relationships | Reflection hallucination | Put source memory ids in the prompt |
| Coordination only in demos | Prompt dressing, no control | Control condition and p < 0.05 |
| Belief bound to wrong agent | Long horizon, context limits | Explicit or external ToM store |
| One operator inflates credit | Sybil attack | DIDs and reputation cost-to-forge |
Questions#
- Does a larger model bargain better?
- No. It writes better language with similar strategic error.
- Why does Contract Net scale past 100 workers?
- It is broadcast-and-respond, not synchronous chat.
- Which Smallville part can you drop?
- None. Each ablation hurts believability.
- Why second-price?
- Under monotone aggregation, agents bid their true value.
- When do agent economies make sense?
- Open networks, verifiable outputs, long-horizon work.
Ship checklist#
- Bound bargaining to 3-5 rounds. Escalate to a mediator on deadlock.
- Reject out-of-ZOPA offers at the protocol boundary.
- Memory is append-only. Corrections are new entries.
- Log the top-k memories that drove each action.
- Start with reputation, not tokens.
- Verify before you reward.