Skip to content

Blog

The Two Genie Game

Every research project begins with a question. This one began with a disagreement.

A former colleague and I were discussing AI assistants. I argued that systems willing to deliberate—to ask clarifying questions, consider alternatives, and refuse requests when necessary—ought to produce better outcomes than assistants trained primarily to maximize user approval. He agreed they might produce better outcomes, but doubted they could ever compete. Every clarification, every refusal, and every additional moment spent thinking is a cost paid by the user. If another assistant answers immediately and confidently, why would people choose the slower one?

Neither of us could answer that question from intuition alone, so I turned it into a mathematical thought experiment. That thought experiment eventually grew into a formal game-theoretic model and, ultimately, the accompanying paper. This post is a less technical account of what I learned while building it.

Village with two genies

Hosting a More Efficient TeaParty

After the 13-hour POC, I rebuilt TeaParty as v0.99. Four architectural changes:

  1. CFA implemented as a skill graph. The Conversation-for-Action protocol (intent, plan, execute, phase gates, backtracks) is expressed as a skill graph rather than as custom orchestrator code. Each node is a skill; transitions are edges; the graph is the protocol.
  2. Bus-driven dispatch with session resume on wake. Parents sleep on the bus until a child message arrives, then resume their prior Claude session to handle it rather than starting a fresh one. No CPU burned waiting, and the conversation prefix stays cached across the wait. Replaces the POC's polling fan-in. The [wake] and [send] rules and the per-instance state continuity (Claude session handle + worktree) live in the CFA engineering spec.
  3. Bounded fan-out at every dispatching parent, capped at three children with bus-driven backpressure. The cap is per-parent, not global: with the project-lead fanning out to three team-leads and each team-lead fanning out to three specialists, up to nine specialist threads could run concurrently in principle. That ceiling has not been hit in practice; parents stagger their dispatches and the observed peak stays lower. Replaces the POC's unbounded burst dispatch that hit provider rate limits in wave 1. The cap (currently 3) lives in the CFA engineering spec.
  4. Configurable workgroups. In the POC, workers were generated on the fly with default prompts. In v0.99, the workgroup is part of the project configuration: each role has a committed agent.md (system prompt), tool allowlist, model choice, and skill set. The stable per-role prompts give Anthropic's prompt cache a consistent prefix to key on across sessions. They also encode role-specific disciplines such as the POINT-NOT-PASTE rule (specialists reference files by path, never paste content into messages). See markdown-writer's agent.md for an example.

This post compares v0.99's measured behavior against the POC's on the same prompt. Token-level numbers for both runs come from the Claude SDK's per-session stream archive (~/.claude/projects/...), which captures input/output/cache token counts per turn for every agent in either architecture. The May 2 run produced a 70,601-word manuscript in 10 hours 36 minutes of wall-clock, with zero rate-limit failures across 75 dispatches and 93% prompt-cache hit on input.

Memory for a Proxy Agent

Permission systems for AI agents fail at both extremes. Click approve on every prompt and within an hour you stop reading them; the agent runs effectively unsupervised. Turn permissions off and you've made the same trade more honestly. Claude Code's auto mode handles the yes/no end of this for routine actions, but most of the questions I want a teammate to field aren't yes/no. They're stylistic choices that depend on knowing what I'd say. Does the team's stated intent capture the brief, or is it missing the lessons from the last attempt? Does this plan need a redirect before it kicks off?

What I want is a proxy. An agent that sits between me and the agentic team, fielding the questions other agents raise, answering the way I would, and bumping things back to me only when it's actually uncertain. The authority to act on my behalf has to be earned: the proxy gets to answer when its model of how I respond to this kind of question in this kind of situation has been calibrated against what I actually do.

The proxy is part of TeaParty, a multi-agent workflow orchestrator I'm building for agentic teams: planning agents, leads, executors, reviewers, and the proxy that fields the questions any of them raise on my behalf. Below is the memory architecture that makes that calibration possible, and what one session looked like.

All You Need Are Skill (Graphs)

Here's a problem you've probably hit.

You want an AI agent to do something non-trivial: pick up a GitHub issue, figure out what's wrong, write tests, fix the code, verify its own work, and merge. A real workflow with branches, loops, and the good sense to stop and ask a human when it's confused.

My First 13-Hour TeaParty

I just ran TeaParty's first end-to-end test. The goal was to see whether the agents could take a real prompt from intent through plan and execute to a coherent deliverable. The prompt:

I would like a book on the universal nature of humor. There are certain types of humor that transcend time, culture and language (e.g. comedy wildlife photos, physical humor, affiliative humor, etc). This is a 5-7 chapter book, targeting armchair enthusiasts, and should explore this phenomena across cultural, temporal, language, belief, and technological boundaries. Thesis: Humor is what unites us.

Dialog with the Genie

Prompt engineering tells us we can talk to a large language model the way the wisher talks to the genie: word the wish exactly right, and we'll get exactly what we asked for. The genie isn't malicious, just naive. It is doing its best to satisfy a wish whose intent it cannot see. The wisher always gets what they asked for. The wisher never gets what they wanted.

Two-panel cartoon: a man kneeling before a green genie wishes "I want to be rich." In the second panel, with a POOF, the man has been turned into a gold statue. The genie watches, arms folded, unchanged.

Exactly what was asked for, never what was wanted.

Human projects know this failure mode well, with no malice in the system at all. The customer asks for one thing and means another, not because they are careless but because most of what makes a result good is invisible to them until they see a version that violates it. Each handoff in the chain bends the request a little further from what was meant, and at the end of it the customer recognizes nothing of what they asked for. What works is dialog: both parties seeking mutual understanding, not once, not just at the end, but whenever questions arise.

Making Comics with an AI Collaborator

A bunch of friends from work and I were running the Wild Beyond the Witchlight D&D campaign. The hook of that adventure is that every character starts cursed in some strange way, and the curses are real inconvenient. One of us lost his ability to focus and was constantly distracted by anything that sparkled. My character lost his sense of direction; north was wherever I happened to be facing. Another lost his sense of self-preservation entirely.

The campaign became, week over week, a parade of unforced errors. One of us was convinced he could fix a hot-air balloon mid-flight and managed to make it worse before falling off. The self-preservation-impaired monk spent the moments immediately after a successful parley trying to intimidate an overwhelmingly larger force of bandits. Most sessions ended with someone laughing hard enough to pause the game.

As the scribe of the group, I'd been writing meeting notes after every session. Meeting notes were a wildly inadequate medium for the material. The comedy of our adventures was a visual storytelling problem.

The other thing about me: I read comics all through high school and college. Batman, Superman, Wolverine, the X-Men crossovers that came out twice a year and contradicted themselves on the second issue. I mostly gave them up as I got older, selling the long boxes off in two rounds: first to buy Magic cards, then years later to buy a 3D printer. The Iron Man movie reawakened my love of comics as an artform. It also did something else, and I know a lot of you feel the same way. It made me want Jarvis.

Lazy Symbolic Bayesian Inference: A Compiler for Junction Trees

Most exact-inference libraries treat junction-tree calibration as a numerical procedure: build the tree, run two passes of message passing, return the marginals. Change the evidence and the whole pass runs again. PyBayes treats it as a compiler problem instead. The junction tree is built once, then the calibration is reified as a symbolic computation DAG of typed algebraic terms. A parallel heap of torch.Tensor thunks hangs off that DAG, indexed by the same identifiers, evaluated on demand and invalidated selectively when evidence changes. The library is PyBayes (github.com/dlewissandy/pybayes).

Yet Another Primer on Bayes Nets

A walking-pace introduction to exact inference for discrete Bayesian networks: what they are, what we ask of them, why naive inference is intractable, and how junction trees turn it into a sequence of local computations. Aimed at someone who knows probability and graphs but hasn't worked with Bayesian networks specifically. By the end you should be able to read the algorithm in a graphical-models paper, recognise when exact inference is tractable for a given network, and trace why two variables are or aren't conditionally independent given some set of observations. The running example is the Asia network (Lauritzen and Spiegelhalter 1988); each algorithm is walked through end-to-end on it.

Finding the Right Shape: Implementing BLAS in Haskell

Based on a presentation given in March 2017. The slides contain the full source listings, the simplifier output, and the benchmark plots that this post summarises.

There is an idea, first articulated by Lex Augusteijn in his 1998 paper Sorting Morphisms and later made central to Jeremy Gibbons' 2003 chapter Origami Programming, that has stayed with me ever since: many divide-and-conquer algorithms are determined purely by their recursion pattern. Once you have fixed the right shape for the computation, there are essentially no further design decisions to be made. The algorithm writes itself. Fold the problem on the natural axis and the structure of the computation reveals itself; fold it wrong and you end up writing Fortran by hand, special-casing every traversal, unrolling every loop.

lambda-blas was a six-month attempt to test that claim against an unforgiving benchmark: dense numerical linear algebra. Could the inner loops of BLAS, the de facto reference for dense linear algebra since the 1970s, be expressed as simple compositions of folds and unfolds and still run as fast as the reference Fortran? The answer turned out to be yes. The library is lambda-blas and it is public on GitHub.