Forming a government the llm way
It’s been a week since the Swedish general election and although I am interested in politics I don’t look forward to weeks of negotiations about who can negotiate with whom or can’t be in the same room as someone else. In Swedish we say there’ll be a shitload of “käbbel”, and I can’t stand it. There has to be a better way.
Maybe send one representative from each party out on a parking lot with an iron bar and, well, solve it. Or play chess about. Or…checks notes, what’s the latest hype again…let AI deal with it.
So this is a fun experiment, why not codify the parties’ positions in different policy areas, let them have their red lines and then let agents negotiate the outcome and see where it lands? This is not an novel idea, it’s been done many, times before but I haven’t seen an example targeted directly at the Swedish situation. What also makes it interesting is that in a known political environment you can play around with the policy areas and to see where it lands.
Meet kbbl (short for “käbbel”), it’s a simple framework for codifying party policy positions and a loop which allows one party at a time to attempt to form a government (yes, that’s a “talmansrund”, fika not incluced).
In this very prototypish implmentation, there are ten different policy areas (economy, education, health, military and so on) and each party is positioned on a scale from -5 to 5. The goal for the agents are then to try to negotiate a platform based on the same policies that they can accept to join or support the government. In addition to the policy areas, each party also codifies the willingness to go to a re-election.
Here’s the positioning of S post election:
{
"name": "S",
"seats": 99,
"positions": {
"economic": -3,
"environment": 1,
"military": 3,
"health": -4,
"immigration": -1,
"law_and_order": 2,
"education": -3,
"transport": 1,
"social": 2,
"international": 3
},
"prefer_not": [
"SD"
],
"to_govern": [
{
"axis": "economic",
"op": "<=",
"value": -2
},
{
"axis": "health",
"op": "<=",
"value": -3
},
{
"text": "no profit extraction from tax-funded schools or elderly care"
}
],
"to_support": [
{
"axis": "economic",
"op": "<=",
"value": 0
},
{
"text": "no cuts to unemployment insurance"
}
],
"willingness_to_re_elect": 4
}
The parties meet on the iniative of the party that has got the task to try to form the government, in this case S. Here’s an example of a negotiation exchange:
Run: riksdag-2026
Formateur: S
Round 4 of 5 — S meets L
------------------------
Why S chose L
Meeting L next — extra insurance. Current math is tight (173 opposition vs 175
needed), so securing L's abstention protects against any single defection unraveling
the coalition.
S:
L, I'm forming a government and don't need you in cabinet, but I'd value your
abstention rather than a no-confidence vote. What would it take for L to stand aside
on this one?
L:
L can support from outside on reasonable terms, but our floor is education at +2 or
higher — non-negotiable given our base. On international, we'd need at least +3; we
campaigned hardest there. Meet those two and we abstain or even back you formally.
What's your platform on those axes?
S:
International at +3 matches my platform already — that's easy. Education at +2 is
too far from where I stand; I can't move past -1 without breaking faith with my own
base. If that's a hard floor for you, we may simply agree to disagree.
L:
-1 is a non-starter for us on education — that's the axis our voters feel most. I
could stretch our floor down to +1 if you move meaningfully off -1, paired with firm
+3 on international. Otherwise we're headed for a no-confidence vote, and neither of
us wants that election.
S:
I understand education matters deeply to you, but I can't move past -1 without
breaking my own mandate — that's my final offer. If that's not enough, I respect it,
and we'll proceed without your support rather than misrepresent where I actually
stand.
L:
-1 on education is too far from our mandate to support, even from outside — that's a
betrayal we can't sell to our voters. We won't back this government, though we may
not lead the charge against it either. No deal here.
Ended: L declared impasse, after 6 Exchanges.
In the end, there’s a proposal, which the kbbl-loop will then let the parties vote on, for example:
The Proposal
------------
This coalition — S, V in cabinet with MP, C, KD backing from outside — clears every
bar I set myself and every price my partners charged: economic -4, health -4,
statutory profit ban, environment/transport +2, no new nuclear, law_and_order +2, SD
locked out entirely. That's 198 seats behind it, comfortably past the 175 needed to
survive. It costs me ground on education and social relative to ambition, but
nothing that breaks faith with my mandate — I hold my core economic and health lines
firmly. This is a stable, disciplined government worth tabling.
S's Proposal.
Platform:
economic -4
environment +2
military +3
health -4
immigration -1
law_and_order +2
education -1
transport +2
social +2
international +3
Government: S, V
Support-only: MP, C, KD
198 seats are behind it, in cabinet or outside it. It takes 175 voting No to defeat it.
It also commits the government to:
- no profit extraction from tax-funded schools or elderly care
- profit in tax-funded welfare banned in law this term
- no new nuclear this term
- SD has no influence over government policy
The Vote
--------
S votes Yes:
This delivers my core cabinet price on economic and health, bans profit extraction
in welfare, locks out SD entirely, and secures broad backing. Education and
transport drift further than I'd like, but the mean gap is small and the deal is
strong overall — I vote Yes.
M votes No:
This platform betrays economic and health worst-of-all, with nothing offered to us.
We were never courted, so we owe them no cover. I will not spend our seats propping
up a government that gutted our core demands without so much as asking.
SD votes No:
This platform ignores every red line: immigration at -1, law_and_order at +2, no
moratorium, and it explicitly excludes SD from influence. My voters gave me these
mandates for a reason. I vote No.
V votes Yes:
Economic and health targets are met, the profit ban is codified, and V holds real
ground on environment and transport. Military and international sting, but this
secures cabinet influence and delivers my core welfare demands — worth backing.
C votes Abstain:
Environment and SD conditions are met as I required. The economic and health lines
cut deep against our platform, but that wasn't part of what I demanded to stand
aside. I'll honor the terms I set: C abstains, letting this pass without our support
in cabinet.
KD votes Abstain:
Law_and_order at +2 meets exactly what I asked for abstention. The rest is far from
our mandate on economic and social, but we named our price and it's been met — I
won't renege on that. KD abstains, as agreed.
MP votes Yes:
My named price—environment ≥+2—is met, and no new nuclear holds. Immigration and
law_and_order sting badly, but that's the cost of outside support, not cabinet. I
said I'd back this; I will.
L votes Abstain:
This platform betrays nearly everything L campaigned on—economic, health, and
education gaps are unacceptable, and none of our asks were met. We won't own this by
voting Yes, but we also won't be the ones forcing another election. We abstain.
Vote on S's Proposal.
Party Seats Vote
------- ----- -------
S 99 Yes
M 70 No
SD 62 No
V 30 Yes
C 25 Abstain
KD 22 Abstain
MP 22 Yes
L 19 Abstain
------- ----- -------
Yes 151
Abstain 66
No 132
Government: S, V. Support-only: MP, C, KD. 198 seats behind it.
132 seats voted No, and it takes 175 to defeat a Proposal. It passes.
As you can see, there’s quite a lot to iron out regarding the logics and dynamics in the negotiation and it seems like the LLMs are a little too happy to agree compared to the real parties.
Unfortunately, I won’t publish this to test as it costs a bit of money to run but if you want to run it yourself, the code is on github.