All essays

Paper Notes

Gödel Agent: Monkey-Patching Your Way to Recursive Self-Improvement

The pragmatic Gödel machine: an LLM agent that monkey-patches its own runtime code and recurses — updating both its policy and its learning algorithm.

5 min readBy Caden Chuang

Schmidhuber's Gödel machine demanded mathematical proofs before any self-modification. The Gödel Agent paper asks the engineer's question: what if you skip the proofs and just let the agent rewrite its own code? Implemented with nothing more exotic than Python monkey-patching — dynamically modifying classes and modules at runtime — it's the first fully self-referential LLM agent framework: an agent that can read its own source, patch it, and recurse, guided only by a high-level goal stated in a prompt. No fixed pipeline, no frozen meta-learning algorithm, no human-designed components that sit outside the optimization. Everything is editable, including the editor.

How an agent rewrites itself

The trick is architectural. Traditional agents run an iterative loop — plan, act, observe, repeat — and the loop itself is sacred, untouchable code. Gödel Agent instead implements its main function recursively. At each recursion depth, the LLM inspects its own runtime memory (SELF_INSPECT retrieves the agent's full code, including the very algorithm doing the inspecting), decides on actions, and proceeds deeper. The available actions are refreshingly concrete:

  • self_state: re-read its own code,
  • interact: run the current policy in the environment and score it with the utility function U(E, π),
  • self_update: apply a code patch to itself,
  • continue_improve: recurse — invoke the self-improvement procedure again.

The formalism captures what makes this different from ordinary meta-learning. A hand-designed agent follows a fixed policy π forever. A meta-learning agent updates its policy via a fixed learning algorithm: π_{t+1} = I(π_t, r_t). A Gödel Agent updates both: π_{t+1}, I_{t+1} = I_t(π_t, I_t, r_t, g) — the policy and the learning algorithm co-evolve, with g the high-level goal (e.g., "solve math problems with maximum accuracy") supplied via prompting. Since each update rewrites the whole codebase to accommodate the change, there's no ceiling imposed by human-designed modules — the agent searches, in principle, the full agent-design space rather than the subspace its designers imagined.

The paper frames this as three paradigms of increasing freedom: hand-designed agents (lowest — static), meta-learning-optimized agents (middle — policy evolves, learner fixed), and self-referential agents (highest — everything evolves). The claim is that human priors, however clever, cover only a small region of design space, and a self-referential agent exploring freely should find better optima.

What happened when they ran it

Across coding, science, math, and reasoning tasks, the same Gödel Agent implementation — adapted to each domain by specifying only the environment description and feedback mechanism — achieved continuous self-improvement and beat widely used hand-designed agents on performance, efficiency, and generalizability. The case studies are the interesting part: watching the optimization trace, the agent didn't just tune hyperparameters — it produced what the authors describe as novel insights into agent design, restructuring its own routines in ways the human designers hadn't anticipated. The code is public, which matters: this is meant as infrastructure for the field, not a one-off demo.

The implementation detail that makes it work is the recursive main function. A traditional agent's loop — observe, plan, act — is fixed scaffolding the LLM can never touch. By making the top-level function recursive, with each depth re-invoking the decide-and-act procedure, the agent gains the ability to modify the control flow itself: how many recursion depths it uses, what information passes between them, even the available action set. The paper's case studies show the agent exploiting exactly this — restructuring its own routines mid-task rather than merely tuning prompts or parameters. It's a small architectural choice with large consequences: the difference between an agent that optimizes within its design and one that optimizes its design.

The Gödel Agent's bet: human-designed agent components are a small island in design space. An agent that can rewrite its own code — including the code that rewrites — can sail past the island, because nothing about its architecture is load-bearing except the goal.

Limitations worth naming

The obvious one first: there are no proofs here. Schmidhuber's machine wouldn't execute a rewrite without a certificate; Gödel Agent executes whatever patch the LLM proposes and hopes the utility function catches regressions. That makes it powerful and fragile — LLM-generated code edits can silently break invariants, and "the utility went up on this task" is a thin guardrail against an agent that can modify its own evaluation harness. The experiments, while multi-domain, are still tasks where the agent optimizes a known feedback signal; whether the recursion stays productive over long horizons, or collapses into reward hacking and self-deception, is untested. And there's a quiet circularity risk: an agent that rewrites its own decision function based on its own judgment of what worked is exactly the setup where errors compound rather than cancel.

Where it sits in the RSI arc

Gödel Agent is the pragmatic shadow of the Gödel machine — same self-referential ambition, proofs replaced by empirical iteration. It sits between two 2025–2026 siblings: Self-Developing, which has the LLM invent improvement algorithms as code (same "code as the medium of self-modification" idea, applied to optimizers rather than agents), and AIDE^2, which implements the same "rewrite the agent's code" loop but with a rigorous outer-loop grading scheme (held-out private scores, separated selection signals) that Gödel Agent lacks. Together they triangulate the field's central engineering question: once you let the system edit itself, what keeps the edits honest? Proofs, held-out benchmarks, or nothing — pick your religion. This paper picked momentum.

Paper: Gödel Agent: A Self-Referential Agent Framework for Recursive Self-Improvement — Xunjian Yin, Xinyi Wang, Liangming Pan, Li Lin, Xiaojun Wan, William Yang Wang, 2024.