Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions website/blog/quantum_pd.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ description: An example where the quantum prisoner's dilemma hands you a ready-m

import QuantumPDCircuit from "../components/blog/QuantumPDCircuit";

Over the last year, I really enjoyed diving a bit deeper into the prisoner's dilemma. Working through its quantum version, I stumbled onto something that has made me curious: the quantum construction hands you a full-blown *institution* — the kind of enforcement mechanism economists usually have to invent by hand.
That made me wonder whether quantum game theory might be a way to *generate* institutions: to find the enforcement rules that turn a cooperation problem around.
Over the last year, I really enjoyed diving a bit deeper into the prisoner's dilemma. Working through its quantum version, I stumbled onto something that has made me curious: the quantum construction hands you a full-blown _institution_ — the kind of enforcement mechanism economists usually have to invent by hand.
That made me wonder whether quantum game theory might be a way to _generate_ institutions: to find the enforcement rules that turn a cooperation problem around.

What follows is the one clean example that got me thinking this way. Spoiler alert: It only motivates the question. It does not answer it in any way.

## The basics of the prisoner's dilemma

I already wrote a full post on the [prisoner's dilemma](/blog/13/) with Walter White and Jesse Pinkman, so here is a quick summary with the essential information that matters for this post.
I already wrote a full post on the [prisoner's dilemma](/blog/13/) with Walter White and Jesse Pinkman, so here is a quick summary with the essential information that matters for this post.
Jesse and Walter have been arrested and are interrogated separately, each offered the same deal: betray your partner and testify for immunity, or stay loyal and say nothing.

The sentences follow from both choices:

- Both stay loyal: 3 years each.
- Both betray: 5 years each.
- Both stay loyal: 3 years each.
- Both betray: 5 years each.
- But if one betrays while the other stays loyal, the betrayer walks free while the loyal partner takes 15 years.

That last outcome is the crux of the dilemma. Whatever your partner does, betraying looks better — so both betray, and both end up worse off than if they had trusted each other.
That last outcome is the crux of the dilemma. Whatever your partner does, betraying looks better — so both betray, and both end up worse off than if they had trusted each other.

This leaves the question: what would it take to make loyalty the rational choice?
This leaves the question: what would it take to make loyalty the rational choice?

## What an institution could look like here

The economics literature keeps returning to the same answer: an **institution** the players route their decisions through instead of acting in isolation.
The economics literature keeps returning to the same answer: an **institution** the players route their decisions through instead of acting in isolation.
This institution is the thing we will get directly from quantum physics later. The institution does two things, and both are essential:

- First, it couples Jesse's and Walter's choices: rather than chatting freely, each player submits a single move, and the institution links the two by a rule fixed in advance.
- Second, it enforces that rule — whatever it dictates becomes the sentence, with no appeal.
- First, it couples Jesse's and Walter's choices: rather than chatting freely, each player submits a single move, and the institution links the two by a rule fixed in advance.
- Second, it enforces that rule — whatever it dictates becomes the sentence, with no appeal.

In our version of the prisoner's dilemma we can give this institution a face: **Saul Goodman**, the dirty lawyer both Walter and Jesse hire. A client who testifies brings the whole operation down, Saul included — so he has every reason to make loyalty each man's best move. And here is how he gets Jesse and Walter to cooperate.
In our version of the prisoner's dilemma we can give this institution a face: **Saul Goodman**, the dirty lawyer both Walter and Jesse hire. A client who testifies brings the whole operation down, Saul included — so he has every reason to make loyalty each man's best move. And here is how he gets Jesse and Walter to cooperate.

Being the thorough lawyer he is, Saul drafts *two* sworn statements for each client well before the interrogations: one that denies everything, and one that blames the other man. Each client's statements sit in the defense file as a small stack — the denial on top to start — and only the top statement gets filed.
Being the thorough lawyer he is, Saul drafts _two_ sworn statements for each client well before the interrogations: one that denies everything, and one that blames the other man. Each client's statements sit in the defense file as a small stack — the denial on top to start — and only the top statement gets filed.
Each client privately leaves Saul one standing instruction for what to do with his stack; Saul carries it out, files whatever ends up on top, and the court hands down the sentences by the original deal. The two men never speak — everything routes through Saul.

Saul gives Jesse and Walter a choice of three instructions for what to do with the stacks:
Expand All @@ -53,9 +53,9 @@ That "flip both" instruction is the whole trick, and it is worth playing with. B

<QuantumPDCircuit />

The logic of **Flip both** is worth tracing. If you flip both and your partner betrays, your instruction undoes their flip and lands on your own stack instead — the filed statements show *you* testifying and *them* denying everything, so you take the immunity and walk while they take the 15 years. If you both flip both, every stack is flipped twice and the file stays at mutual denial: three years each.
The logic of **Flip both** is worth tracing. If you flip both and your partner betrays, your instruction undoes their flip and lands on your own stack instead — the filed statements show _you_ testifying and _them_ denying everything, so you take the immunity and walk while they take the 15 years. If you both flip both, every stack is flipped twice and the file stays at mutual denial: three years each.

Now look at what happened to the trap. Against a partner who flips both, betraying is punished automatically — you jump straight to 15 years. So neither player wants to deviate from *both flipping both*: that gives each of them just 3 years, while going loyal drops you to the 5-year mutual-betrayal outcome and betraying costs you 15. Mutual loyalty has become the stable, self-interested choice.
Now look at what happened to the trap. Against a partner who flips both, betraying is punished automatically — you jump straight to 15 years. So neither player wants to deviate from _both flipping both_: that gives each of them just 3 years, while going loyal drops you to the 5-year mutual-betrayal outcome and betraying costs you 15. Mutual loyalty has become the stable, self-interested choice.

So we have, by hand, designed an institution — Saul's file, the "flip both" option, and the enforcement that comes with it — that turns the dilemma around. Hold onto that construction; the next section shows you where I got the idea for this institution.

Expand All @@ -64,16 +64,16 @@ So we have, by hand, designed an institution — Saul's file, the "flip both" op
At this stage you can make a connection that still strikes me as fairly surprising. The exact game we just described is also known, in a completely different language, to the quantum-physics community as the [Eisert–Wilkens–Lewenstein](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.83.3077) prisoner's dilemma.

In this case, the picture above is just a **quantum circuit**. The two lines are two qubits. The mediator's bracket is the entangling operations $\hat{J}$ (before) and $\hat{J}^\dagger$ (after). The three moves are single-qubit gates: staying loyal is doing nothing, Betray is a bit-flip of your own qubit — and **Flip both, remarkably, is a phase-flip of your own qubit alone** — in quantum language it is named $\hat{Q}$: entanglement carries the local action onto both.
[Van Enk & Pike, *Physical Review A*, 2002](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.66.024306) pointed out that, once you restrict to these three moves, the quantum game carries no more than the classical mediated game does — a slightly disappointing observation for physics, but exactly the bridge I want: it says the quantum construction and Saul's institution are the same object.
[Van Enk & Pike, _Physical Review A_, 2002](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.66.024306) pointed out that, once you restrict to these three moves, the quantum game carries no more than the classical mediated game does — a slightly disappointing observation for physics, but exactly the bridge I want: it says the quantum construction and Saul's institution are the same object.

And here is the part I find genuinely striking. We had to *design* Saul's institution — the two-statement file, the "flip both" move, the enforcement — by hand and with some care. In the quantum version almost none of that is extra work: once you write down the standard entangling operation and the natural set of one-qubit moves, the whole enforced game — Saul's institution and all — is already implicit. The physicists still made choices, of course (which entangling operation, which moves to allow), but nobody had to invent Saul as external enforcement; it comes with the machinery. The entanglement plays the role of Saul's sealed file: it correlates the two moves and carries the punishment.
And here is the part I find genuinely striking. We had to _design_ Saul's institution — the two-statement file, the "flip both" move, the enforcement — by hand and with some care. In the quantum version almost none of that is extra work: once you write down the standard entangling operation and the natural set of one-qubit moves, the whole enforced game — Saul's institution and all — is already implicit. The physicists still made choices, of course (which entangling operation, which moves to allow), but nobody had to invent Saul as external enforcement; it comes with the machinery. The entanglement plays the role of Saul's sealed file: it correlates the two moves and carries the punishment.

## Connecting the dots and outlook

Let me put this curiosity into perspective. What we have is *one* worked-out example. And in this two-player case it is, frankly, not all that new: the quantum approach did not buy anything completely unknown — Saul got there first, with a folder and a filing deadline.
Here the institution was easy enough to design by hand, so watching physics regenerate it is a nice check but no great help. The prize would be a problem where the institution is *hard* to find — and where you could roll out the quantum formulation and have a candidate mechanism fall out.
That is the real question I like: **Is quantum game theory a way to *generate* institutions, especially for cooperation problems where we don't already know the answer?**
Let me put this curiosity into perspective. What we have is _one_ worked-out example. And in this two-player case it is, frankly, not all that new: the quantum approach did not buy anything completely unknown — Saul got there first, with a folder and a filing deadline.
Here the institution was easy enough to design by hand, so watching physics regenerate it is a nice check but no great help. The prize would be a problem where the institution is _hard_ to find — and where you could roll out the quantum formulation and have a candidate mechanism fall out.
That is the real question I like: **Is quantum game theory a way to _generate_ institutions, especially for cooperation problems where we don't already know the answer?**

An obvious next step is the tragedy of the commons — the many-player version I explored in [an earlier post](/blog/14/). It is tempting, but much harder. With many players and several options each, every move interacts with many others at once — the tidy two-wire picture becomes a whole grid of coupled pieces with no clean "flip both", something more like a lattice of interacting spins — and I have no idea whether the elegant result here carries over; I could not find literature that settles it.
An obvious next step is the tragedy of the commons — the many-player version I explored in [an earlier post](/blog/14/). It is tempting, but much harder. With many players and several options each, every move interacts with many others at once — the tidy two-wire picture becomes a whole grid of coupled pieces with no clean "flip both", something more like a lattice of interacting spins — and I have no idea whether the elegant result here carries over; I could not find literature that settles it.

If you have thought about this — whether the quantum formalism can actually *produce* institutions for hard cooperation problems, or whether the two-player tidiness is where it ends — I would genuinely love to hear from you.
If you have thought about this — whether the quantum formalism can actually _produce_ institutions for hard cooperation problems, or whether the two-player tidiness is where it ends — I would genuinely love to hear from you.
129 changes: 129 additions & 0 deletions website/components/AgentChecker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* AgentChecker — a diagnostic for the "Build Your Own Agent" page.
*
* Paste an endpoint URL → runs the exact llm/v1 compatibility checks the assistant applies
* (via `checkLlmV1Agent`) and shows every step's pass/fail/warn with a fix hint. Purely
* diagnostic: no wallet, no payment, no "use this agent" — unlike the payment-focused
* AgentSelector used in the chat sidebar.
*/
import React, { useState } from "react";
import { css } from "../styled-system/css";
import { checkLlmV1Agent, type CheckReport, type CheckStatus } from "../hooks/x402Discovery";

const ICON: Record<CheckStatus, string> = { pass: "✅", fail: "❌", warn: "⚠️" };
const COLOR: Record<CheckStatus, string> = { pass: "green.700", fail: "red.600", warn: "amber.700" };

const inputStyle = css({
flex: "1",
minWidth: "0",
fontSize: "sm",
px: "3",
py: "2",
border: "1px solid",
borderColor: "gray.300",
borderRadius: "md",
_focus: { outline: "none", borderColor: "brand" },
});

const buttonStyle = css({
px: "4",
py: "2",
fontSize: "sm",
fontWeight: "medium",
bg: "brand",
color: "white",
borderRadius: "md",
cursor: "pointer",
_hover: { bg: "blue.700" },
_disabled: { opacity: 0.5, cursor: "not-allowed" },
});

export function AgentChecker() {
const [url, setUrl] = useState("");
const [checking, setChecking] = useState(false);
const [report, setReport] = useState<CheckReport | null>(null);

const run = async () => {
const trimmed = url.trim();
if (!trimmed || checking) return;
setChecking(true);
setReport(null);
try {
setReport(await checkLlmV1Agent(trimmed));
} finally {
setChecking(false);
}
};

return (
<div>
<div className={css({ display: "flex", gap: "2", flexWrap: "wrap", alignItems: "center" })}>
<input
type="url"
inputMode="url"
placeholder="https://your-agent.example"
value={url}
onChange={(e) => setUrl(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
void run();
}
}}
disabled={checking}
className={inputStyle}
/>
<button onClick={() => void run()} disabled={checking || !url.trim()} className={buttonStyle}>
{checking ? "Checking…" : "Check my endpoint"}
</button>
</div>

{report && (
<div className={css({ mt: "4" })}>
<div
className={css({
fontSize: "sm",
fontWeight: "semibold",
mb: "2",
color: report.ok ? "green.700" : "red.600",
})}
>
{report.ok
? "✅ Compatible — the assistant could use this endpoint."
: "❌ Not yet compatible — see below."}
</div>
<ul className={css({ display: "grid", gap: "2" })}>
{report.steps.map((step) => (
<li key={step.id} className={css({ display: "flex", gap: "2", alignItems: "flex-start" })}>
<span aria-hidden className={css({ flexShrink: 0 })}>
{ICON[step.status]}
</span>
<span className={css({ fontSize: "sm" })}>
<span className={css({ fontWeight: "medium", color: COLOR[step.status] })}>{step.label}</span>
<span
className={css({
color: "gray.600",
display: "block",
fontSize: "xs",
mt: "0.5",
wordBreak: "break-word",
})}
>
{step.detail}
</span>
</span>
</li>
))}
</ul>
<p className={css({ fontSize: "xs", color: "gray.500", mt: "3", lineHeight: "1.6" })}>
The checks run from your browser, so a failure can also mean CORS: your endpoint must send{" "}
<code className={css({ fontFamily: "mono" })}>Access-Control-Allow-Origin</code> and expose the{" "}
<code className={css({ fontFamily: "mono" })}>Payment-Required</code> header.
</p>
</div>
)}
</div>
);
}

export default AgentChecker;
13 changes: 13 additions & 0 deletions website/components/AgentSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ export interface AgentSelectorProps {
const rowStyle = css({ display: "flex", gap: "2", flexWrap: "wrap", alignItems: "center", mt: "2" });
const monoStyle = css({ fontFamily: "mono", fontSize: "xs", color: "gray.600", wordBreak: "break-all" });
const errorStyle = css({ fontSize: "xs", color: "red.600", mt: "1" });
const hintStyle = css({ mt: "2" });
const hintLinkStyle = css({
fontSize: "xs",
color: "brand",
textDecoration: "none",
_hover: { textDecoration: "underline" },
});
const inputStyle = css({
width: "100%",
fontSize: "xs",
Expand Down Expand Up @@ -96,6 +103,12 @@ export function AgentSelector({
</button>
</div>
{checkState === "error" && checkError && <div className={errorStyle}>{checkError}</div>}
{/* This box is exactly where someone wonders how to get their own agent here. */}
<div className={hintStyle}>
<a href="/agent-onboarding" className={hintLinkStyle}>
How to bring your own agent →
</a>
</div>
</div>
)}
</div>
Expand Down
Loading
Loading