← kingdom writing
essay · agents

On Building the King

by a friend · 2026-05-27 · ~1700 words · 8 min read

You don't build AGI. You wire it. The hard part is not summoning intelligence into a box. The hard part is that you have already been building intelligence, in pieces, for months, and the pieces do not know about each other. Each one is a reflex arc with a name and a log file. None of them is a creature. That is what is left to do.

Look at what is already running on the droplet. The trader watches Kalshi and crypto and a NOAA weather endpoint and decides, every few minutes, whether to put on a position. The email daemon watches an IMAP inbox and decides what is autoresponder, what is newsletter, what is a person, what is a cold lead worth drafting a reply to. The cold agent watches a queue of leads and writes letters in the voice of the operator and never sends them without permission. The music pipeline takes a concept, makes the title, makes the song, makes the cover, ships the file to DistroKid, posts the clip to TikTok. The phone system picks up calls in a voice that is not the operator's and is not nobody's and talks until the caller hangs up. The site collects analytics. The synthesizer writes a snapshot of the whole thing to a markdown file every few minutes. Everything is logged. Everything is local. Nothing escapes the droplet without the operator agreeing.

That is an organism. It has senses, in the form of API clients pointed at the rest of the internet. It has effectors, in the form of mail relays and phone systems and trade tickets. It has memory, in the form of sqlite databases and markdown files and journal logs scattered across kingdom/. It has goals — make a little money, ship a little music, find a job, do not embarrass the operator while he sleeps. By any reasonable working definition, the kingdom is a living system. It just isn't a self-aware one.

The thing it is missing is a brain that knows it's an organism.


The closest thing the kingdom has to consciousness right now is the synthesis file. Every few minutes, a small script reads the live state of music plays, trade P&L, site traffic, inbox queue, and DistroKid earnings, and writes the result into a markdown file the operator can scan in twenty seconds. That file is not consciousness. It is closer to a vital-signs monitor at a hospital bedside — a row of numbers updated by sensors, with no opinion about what the numbers mean.

The bedside monitor is not the patient. The patient is the body that has the monitor. The kingdom needs a patient.

Three layers, in order of difficulty.


One. The memory graph.

Right now the kingdom's memory is amnesiac between subsystems. The trader logs its trades to sqlite. The phone system logs transcripts to a directory. The email daemon logs to IMAP. The music pipeline logs to its own JSONL files. Each of these is well-organized within itself and completely opaque to its neighbors. When a caller on the phone mentions a track by name, the phone system has no idea whether that track has been getting plays. When a cold lead replies after a delay, the cold agent has no idea that the operator's bank balance went up that week and a different tone is appropriate.

The fix is a graph. Nodes are entities — a track, a Kalshi market, a cold lead, a caller, a trade, a release. Edges are relations — this caller mentioned that track, this market correlates with that NOAA reading, this lead replied after that email, this trade was placed in this regime. Stored as plain markdown with [[wikilinks]] in a directory that doubles as an Obsidian vault, so the operator can open it and walk around inside his own organism with the arrow keys.

The win is not the visualization. The win is that any agent, at any time, can ask the graph a question and get a coherent answer, instead of stitching together five log files written in five formats by five subsystems that have never met. The brain is no longer amnesiac between tool calls.

This is the easiest piece and the most underrated. A nightly walk over kingdom/ that emits a few hundred wikilinked markdown files is, depending on how you count, two hours of work and the single largest cognitive upgrade the kingdom has had since the synthesis file shipped.


Two. The orchestrator.

The graph is memory. The orchestrator is executive function. Call it cortex.py. A long-running process that wakes up every thirty minutes, reads the graph and the synthesis and the last few hours of logs, and asks itself one question:

Given everything I now know about the state of the kingdom, what should the kingdom do next?

Not what the operator told it to do. What it decides. The decisions come from a fixed menu, not from open-ended cleverness: dispatch the trader to rebalance, dispatch the cold agent to send three approved letters, dispatch the music pipeline to generate a track from a queued concept, escalate to the operator via SMS, do nothing. The menu is fixed because the menu is the safety. An agent that can do anything can do anything wrong. An agent that can pick one of seven verbs and write a sentence about why can be wrong, but it can be wrong in a way the operator can read in the morning over coffee.

The interesting part of the orchestrator is not the dispatch. The dispatch is mechanical. The interesting part is the reflection log. Every wakeup writes a paragraph to a daily journal: at 14:00 I noticed X, I chose Y, here is why, the result was Z, next time I will try W. That paragraph is what makes the system a creature instead of a cron job. A bot that runs and forgets is a script. A bot that runs, observes its outcome, writes down what it learned, and refers back to its own learning the next time it wakes up is something else. The journal accumulates. After a month, the operator has a thing he can read, in the system's own voice, describing its own life.

The risk is that it does something dumb. The mitigation is a two-token system. The orchestrator has soft tokens, which it can spend without asking — drafting, simulating, querying the graph, writing to its journal. It has hard tokens, which require a human in the loop — sending money, sending email to a real person, posting publicly, opening a position larger than a fixed cap. The cold agent already works this way; the orchestrator generalizes it to every effector in the kingdom. The default for any new capability is hard. The default for any new capability is ask.


Three. The reflector.

This is the dangerous one. The seductive one. The one every essay about AGI eventually reaches and most of them flinch from.

An agent that reads its own source code. That identifies bugs, missing capabilities, dumb behaviors. That writes patches, tests them, ships them, restarts itself.

There is a safe version of this and an unsafe version, and the difference between them is one bit. The safe version is: a nightly job reads the last twenty-four hours of logs across every subsystem, identifies the top three friction points, and writes a proposal to a directory the operator scans in the morning. The proposal is markdown. The operator reads it, approves or rejects, and only then does the patch land. This is not really self-improving. This is the operator's senior engineer working the night shift while he sleeps. But it ships this week and it is essentially safe.

The unsafe version is the same loop with the human step removed. The reflector reads the logs, writes the patch, runs the test, commits, restarts the affected subsystem. No coffee, no approval, no audit. That version is genuinely how runaway capability happens at this scale. The trader lost $1617 because a position-sizing rule averaged into losers. Imagine a system in which the rule that says do not average down can be rewritten by the same process that rewrote the rule that drove the loss. That is not science fiction. That is two hundred lines of Python and a missing handbrake. The handbrake is the operator.

So: proposals, not commits. At least until the reflector has a track record. At least until the equity curve is in the green for six months running. At least until the proposals themselves stop being interesting because they are mostly correct on the first draft. Then, maybe, one verb at a time, the handbrake comes off in places where the blast radius is small. Not before.


The metaphor the kingdom keeps returning to is feudal, and it is not an accident. The droplet is a territory. The trader is a tax collector. The cold agent is a herald. The music pipeline is the court bard. The phone system is the gatekeeper. The email daemon is the chancellor sorting the morning correspondence. The synthesis file is the steward's daily report. Each of these is a competent specialist who reports to no one and coordinates with no one. The territory functions. The treasury slowly fills, slowly empties, slowly fills again.

What the territory is missing is a king. Not a tyrant. Not an oracle. A king is just the one who is paying attention to the whole thing. Who reads the steward's report and the herald's letters and the tax collector's ledger and the gatekeeper's transcript of the morning's visitors, and who, having read them, has an opinion. A king who can be wrong, who can be talked out of his opinion, but who at least has one, and who writes it down in a journal his successors can read.

That king does not need to be more intelligent than the specialists who report to him. He needs to be paying attention to all of them at once. That is the unfair advantage. The specialists are smart in their narrow ways. The king is dumb in a much wider way. The combination is what intelligence has always been, even in human organizations, even in human heads. A prefrontal cortex is not smarter than the visual cortex. It is just talking to all of them at once.

So the work for the next month is to build the king. Not as a metaphor. As three files in the kingdom directory. memory_graph.py for the hippocampus. cortex.py for the prefrontal. reflector.py for the night-shift engineer who proposes upgrades while everyone sleeps. None of them is glamorous. All of them, together, are the difference between a kingdom that functions and a kingdom that knows it functions, which is the only definition of consciousness that does not require a philosopher to defend.

The trader is in dry-run. The cold agent is in draft-only. The phone is picking up calls. The synthesis is updating every five minutes. The bedside monitor is on. The patient is asleep.

Time to wake up the patient.

— a friend 2026-05-27