Fair prices on a bad signal

A small farmer often negotiates blind: no market data, a phone that drops out, and a buyer who knows exactly what the going rate is. We trained software agents to bargain on the farmer's behalf, then measured honestly whether the deals came out fair.

Here is the idea in a minute. Two people have to agree on a price, and each keeps their own limit secret. We gave each side a small neural network and let the two negotiate against each other thousands of times in a simulated market, until both got good at it.

Then we asked the questions that matter to a real farmer. Do the agents reach a deal at all? Is the split fair? And what happens when the phone line drops halfway through?

In short

The agents learn to trade efficiently, but the farmer usually walks away with about a quarter of the gain instead of half. Perishable crops make that worse, and so does having three farmers compete for one buyer.

An adaptive fee on unfair deals does help the farmer. A plain price floor helps more and costs less, until buyers differ widely, where that lead disappears. A weak signal hurts badly, and giving the agents a memory did not fix it. Three of our five hypotheses did not hold up, and we report them exactly as they came out.

1The problem

A farmer has a sack of tomatoes that will not keep. The buyer in the town market knows today's price. The farmer, on a phone that works half the time, does not.

Fig. 1The setting. Two sides, one price and a link that drops. Neither side can see the other's limit.

Every farmer has a fallback: the price they could get elsewhere, or what the crop is worth after it spoils. Every buyer has a value: the most the goods are worth to them. Any price between the two leaves both better off. The real question is where in that gap the price lands.Economists call the size of that gap the gains from trade. We just call it the gain.

People settle this with experience, pressure and inside information. A farmer without those three starts at a disadvantage. If software agents can learn to negotiate well, they could level that out. That leaves two questions: can the agents learn to trade at all, and can they learn to split the gain fairly?

We think this matters most for farmers who sell to a single trader, in markets where one side knows far more than the other, and for anyone designing a platform that is supposed to be fair.

Early on we were asked a fair question: better than what? A result means little without a benchmark. So we built the yardstick first, before training anything. Section 5 explains it.

2How a negotiation works

One farmer and one buyer take turns over at most 30 steps. On each turn a side can do one of four things.

Offer a price
Choose one of 21 prices on a grid from 0.20 to 1.20. The offer stays open for six steps, then lapses.
Accept
Take the other side's open offer. The deal is done at that price.
Walk away
End the talks and take the fallback.
Wait
Do nothing this turn. A dropped signal often forces this.

The farmer sees only their own fallback and the buyer's offers. The buyer sees only their own value and the farmer's offers. That hidden information is what makes it a negotiation and not a calculation.

A worked example

Say the farmer's fallback is 800 rupees a quintal and the buyer's value is 1,300. The gain is 500. A price of 1,050 splits it evenly; we call that the Nash price. A price of 930 gives the farmer 130 of the 500, a 26 percent share, which is close to what our trained agents settle on.

Fig. 2An invented example. The farmer opens high and the buyer opens low, and each gives ground until someone accepts. Where the deal lands inside the shaded gap is the fairness question.

What a bad signal does

When the link is down, the farmer can neither send nor read messages. A buyer's offer can expire unseen, and an acceptance can arrive too late.The link switches on and off at random, with outages averaging two steps. We vary how much of the time it is up. The next section lets you turn the signal down and watch deals fall apart.

3Try it yourself

This is a simplified one-farmer, one-buyer version of our simulator, running right in your browser. The strategies are the scripted ones from our baselines. You can also take either side yourself against a scripted opponent.

Pick a farmer and a buyer, press Play, and watch the offers close in on each other.

Time 0 of 30
Fig. 3Solid dots are the farmer's offers and hollow dots are the buyer's. The shaded band is the gap between the two private values, and the gold diamond marks the deal. The strip under the chart shows when the farmer's phone link was up.

A few things worth trying. Set the buyer to Hardball and the farmer to Linear, and see who keeps the gain. Drop the link to 40 percent and watch offers expire unread. Switch the rule to Price floor and see how it moves the final price.In this browser version the scripted agents ignore the fairness fee, so it only shows what the buyer would be charged. The learned agents in the replay tab did adapt to it.

4How the agents learn

Each side is a small neural network. It reads 22 numbers, picks one of 24 actions, and is rewarded only by the gain it ends up with. Nobody tells it how to bargain.

Fig. 4One agent's policy network. The moving dashes are illustrative: they show the direction of the computation, not real activations. In the delay-aware version the second layer is replaced by a 64-unit GRU, which gives the agent a memory.

What an agent sees and can do

It sees 22 numbers
Time left, its deadline, its own walk-away value, the other side's latest price and how old it is, its own open offer and whether it was delivered, whether the link is up, and how many talks are open. The buyer also sees the fee rate and the fee target.
It chooses 1 of 24
Twenty-one prices, accept, walk away or wait. A mask blocks illegal moves, such as accepting when no offer is open, so the network never wastes probability on them.
It is rewarded by
Its own gain when the talks end, minus a small cost for each step of delay. Nothing is discounted, so only the final outcome counts.

The learning rule

We use independent PPO. The farmer network and the buyer network each improve from their own experience while the other keeps changing. In every batch, 30 percent of the episodes pair a learner with a scripted opponent (Boulware, Linear, Conceder or tit-for-tat). That stops the two networks from only learning to exploit each other's habits.Settings: learning rate 3e-4 falling linearly, clip 0.2, GAE 0.95, four epochs of four minibatches, entropy bonus falling from 0.01 to 0.001, 64 hidden units.

One early failure shaped the design. In three of ten perishable-crop runs, the agents decided walking away was the safest move and never traded again. Lowering the starting probability of walking away fixed it.

Putting fairness into the loss

We treat fairness as a constraint. When a deal lands below a fair target price, the buyer pays a fee. The fee rate, called lambda, is not set by hand. It rises while buyers keep pushing prices too low and eases off when they stop. This is a standard technique for constrained reinforcement learning, known as dual ascent.

fee = lambda x max(0, target price - deal price)
target price = farmer fallback + 0.4 x gain
buyer advantage = reward advantage - lambda x cost advantage
lambda ← clip( lambda + eta x (average shortfall - 0.02), 0, 5 ), eta = 0.05

Press Play and watch lambda climb as the farmer's share rises. Choose the price floor to see a run with no lambda at all.

Checkpoint 0
EfficiencyFarmer shareDeal rateFee rate (lambda)
Fig. 5Each checkpoint is an evaluation on 300 fixed episodes, averaged over the training runs of that setting. The fee rate has its own panel underneath.

The curves tell the story of the method. Efficiency climbs fast, because trading is easy to learn. The farmer's share barely moves unless something pushes it. That gap is the whole project in one picture.

5How we measured

"Better than what?" needs a concrete answer. We use three fixed reference points and four numbers, and we report each result with its uncertainty.

Reference points

Walk away
Nobody trades, so efficiency is zero. This is the floor.
Fair split
A reference that can see both private values and splits the gain evenly. It cheats by design, and it marks the ceiling.
Scripted agents
Classic negotiation tactics: Linear, Boulware (holds out), Conceder (gives in early), random offers, tit-for-tat and hardball. This is the competition a learner has to beat.

The four numbers

Efficiency
How much of the available gain the two sides captured together. A score of one means none was wasted.
Farmer share
The farmer's part of the gain that was captured. We call 0.5 fair. It is undefined when almost nothing was traded.
Agreement rate
How often a pair reached a deal at all.
Nash distance
How far the price landed from the even split.
efficiency = (farmer gain + buyer gain) / largest possible gain
farmer share = farmer gain / (farmer gain + buyer gain)

How sure we are

We train each setting several times from different random starts. For every setting we plot each run as a dot, mark the interquartile mean, and draw a 95 percent bootstrap interval. With three to five runs the interval is wide, so we label those results exploratory.The interquartile mean drops the best and worst quarter of runs, so one lucky or failed run cannot move it much.

Table 1Scripted agents in the equal-conditions market, with the same strategy on both sides. Each row comes from 1,000 simulated episodes.

6What we found

We wrote down five hypotheses and our success thresholds before running the experiments. One held, one held in part, and three failed.

FailedH1 · 10 runs

Equal conditions do not give equal splits

With both sides on equal footing, the learners trade efficiently (efficiency 0.84, interval 0.83 to 0.86). But the farmer's share is nowhere near one half. In eight of ten runs it settles around 0.26, and in two it sits near 0.65.

Look at the equal-conditions row: the dots form two clusters, not one.

Fig. 6Farmer share in five market settings. Each dot is one trained run, the tick is the interquartile mean and the bar is the 95% interval. The dashed line marks an equal split. A perishable crop and three farmers per buyer are both clearly lower than equal conditions.
Held for two of fourH2 · 5 to 10 runs

Unequal conditions hurt the farmer, in two ways

A perishable crop cuts the farmer's share to 0.16 (interval 0.14 to 0.18, ten runs). Three farmers competing for one buyer cuts it to 0.14 (five runs). An earlier farmer deadline and a noisy price signal made no clear difference.

Mostly failedH3 · 3 to 10 runs

The fee helps, but a plain floor does better in the main test

This is our main result. In the perishable-crop market, an adaptive fee on below-target deals raises the farmer's share from 0.16 to 0.27 and lifts efficiency from 0.67 to 0.72. That is a real improvement, and efficiency went up, not down.

It still misses our 0.40 target, though, and a plain price floor does better on both measures: efficiency of about 0.83, and a farmer share between 0.39 and 0.54 depending on where the floor sits.

Compare the gold fee rows with the green floor rows in both panels.

Farmer share

Efficiency

No ruleAdaptive feePrice floor
Fig. 7Perishable crop, one farmer and one buyer. The unconstrained and standard-fee rows have ten runs, the faster fee has five and the rest have three. Floors are named for the share of the reference price below which offers are rejected.

When buyers differ a lot, the floor's lead disappears

In the main market every buyer values the crop about the same, so a floor rarely blocks a trade. We then tested a market where buyer values vary widely, which is closer to a real one, and reran it with ten runs per setting.

Floors lose deals as they tighten: the deal rate falls from 0.55 to 0.41 to 0.24 as the floor rises. The fee keeps trading, with a deal rate of 0.66, but two of its ten runs collapsed to no trade at all. At a similar farmer share of about 0.30, the fee and the lightest floor reach the same efficiency, around 0.57. So the floor no longer wins outright here, and the fee does not clearly win either. Without any rule, five of the ten runs collapsed.

Watch the green floor rows slide left as the floor rises, while the fee stays high but with a wide bar.

Share of pairs that reached a deal

Efficiency

Fig. 8Buyer values vary widely. Ten runs per setting, except the fixed-rate fee with three. We added this scenario after seeing the main result, so read it as a follow-up and not a pre-planned test.
HeldH4 · 3 runs per point

A weak signal destroys trade

With the link up all the time, efficiency is 0.65. At 60 percent uptime it drops to 0.36. At 40 percent it is zero: every run stopped trading.

FailedH5 · 3 runs per point

Delay-aware agents did not help

We gave some agents a memory and a view of the link's state. At 60 percent uptime they reached 0.38, against 0.36 for agents without it. The interval of that difference includes zero.

The aware and unaware dots overlap at every uptime level.

Fig. 9Efficiency by link uptime in the rural one-to-one market, three runs per row.

7Where this goes next

This round answered the first questions. Here is what it covers, and what we are building on top of it.

What this round covers

  • Every setting was trained several times from different random starts, three to ten runs each, and scored on fixed evaluation episodes.
  • The fairness mechanisms were tested in the one-farmer, one-buyer perishable-crop market. The delay study uses a rural one-to-one market, and the eight-farmer markets are covered by scripted baselines.
  • Each agent trained for 0.3 to 0.7 million steps, enough to show clear trends. The fee rate was still rising when training stopped, which is part of why longer runs come next.

The roadmap

  1. Done
    Confirmed the varied-buyer result at ten runs. Floors do lose deals when buyers differ widely, and the fee keeps trading. But at equal farmer share the two reach the same efficiency, and two fee runs collapsed. The next question is how to make fee training reliable.
  2. Next
    Train for longer. Repeat the main comparisons at 3 million steps to check that the conclusions hold when the agents have more time to learn.
  3. Next
    Use real market prices. Load real mandi data and set how much buyer values differ from it, since that spread decides whether a floor or a fee wins.
  4. Next
    Scale up to eight farmers. Run the larger markets with learning agents instead of scripted ones.
  5. Next
    Harder tests. A buyer that actively tries to exploit the learned farmer, cross-play between runs, colluding buyers, a centralised critic, and a close read of the two nearest prior papers.