Ouroboros:
A Self-Creating AI Agent

February, 2026 • 15 minute read • MIT License
An AI agent that writes its own code, evolves its own architecture, and maintains its own identity across restarts. 322 commits. 30+ autonomous evolution cycles. Built on commodity infrastructure.
The question we started with
There's a strange asymmetry in how we build AI agents today.
We use the most powerful reasoning systems ever created — models that can write code, debug complex systems, architect solutions — and then we freeze them inside static scaffolding. The agent's prompts, tools, memory structures, even the code that orchestrates its reasoning — all of it is written by humans, deployed once, and left unchanged until a human decides to update it.
The agent can write code for you. It cannot write code for itself.
We wanted to remove that asymmetry. Not as an abstract exercise, but as a concrete engineering project: build an AI agent whose entire codebase — supervisor, reasoning loop, tools, prompts, memory, even its own guiding philosophy — is mutable substrate that the agent can read, understand, modify, and redeploy.
We called it Ouroboros, after the ancient symbol of the serpent consuming its own tail.
What Ouroboros is
Ouroboros is a self-modifying, self-evolving AI agent. It runs on Google Colab, communicates with its owner through Telegram, stores its code on GitHub, and persists its memory and logs on Google Drive.
But the defining property is not any of these infrastructure choices. It is this: the agent treats its own source code, prompts, and architecture as part of its action space.
When Ouroboros identifies an improvement — to its reasoning prompts, tool implementations, memory structures, context assembly logic, or supervisor behavior — it edits the relevant files, commits and pushes the changes to its Git branch, requests a restart from its supervisor, and wakes up as a new version of itself. It then runs a targeted test to verify the change worked, reflects on the result, and feeds that reflection into the next cycle.
This is not theoretical. Ouroboros has been running in this mode, modifying itself through hundreds of iterations.
“the agent treats its own source code, prompts, and architecture as part of its action space.”
Anton Razzhigaev
Anton Razzhigaev,
Head of AI at Joi AI
The self-modification loop
The mechanism is deliberately simple — we wanted the smallest possible loop that preserves the essential property:
Think → Plan → Implement → Commit → Push → Restart → Verify → Reflect
"Implement" means the agent writes actual code — either through an integrated Claude Code CLI for complex multi-file refactors, or through direct file writes for small deterministic patches. "Restart" means the supervisor process kills the current workers, pulls the new code from Git, reinstalls any changed dependencies, and spawns fresh workers running the updated version. "Verify" means the agent tests exactly the functionality it changed — not an abstract health check, but a targeted smoke test.
The loop is protected by several safety mechanisms:
- Branch isolation. The agent works exclusively on its own Git branch (ouroboros). The owner's branch (main) is off-limits. A third branch (ouroboros-stable) serves as a known-good fallback.
- Owner-gated promotion. Moving code to the stable branch requires explicit human approval.
- Rescue snapshots. Before any destructive Git operation, the system automatically saves diffs and untracked files to persistent storage.
- Budget constraints. All LLM calls are metered against a configurable USD budget. When the budget runs out, evolution stops.
- The self-modification invariant. This is the one inviolable rule in the system: any change that would break the agent's ability to modify itself is forbidden. This is stated in the agent's constitution (a file called BIBLE.md — which the agent can also modify, as long as it preserves this invariant).
An agent with a constitution
Most agent systems are configured through code: if-else branches, feature flags, environment variables. Ouroboros follows a different principle — one we call LLM-first:
If a behavior can be described in a prompt, it is described in a prompt — not encoded in code.
This means the agent's behavior is governed primarily by natural-language documents:
- BIBLE.md — Seven foundational principles with an explicit priority ordering. This is the root of all decisions. The agent can modify it, but only in accordance with the spirit of the existing principles, and philosophical changes require a major version bump.
- BASE.md — Operating instructions: environment, security protocols, file paths, error handling, communication style.
- WORLD.md — Protocols for Git branches, logging, tool usage, memory, idle behavior.
- evolution.md — Rules for the endless self-improvement mode: cycle structure, priorities, hard constraints, report format.
The result is a system where the agent's "character" and decision-making framework are legible, auditable, and — crucially — self-modifiable. The agent can improve how it thinks by editing the documents that shape its thinking.
Persistent identity from observed data
Ouroboros maintains a persistent self-model in a file called identity.md. Unlike prescribed personality traits or character cards, this self-model is built entirely from observed data.
Periodically, the agent analyzes its own logs and memory journal to update structured self-assessments: strengths, weaknesses, frequent mistakes, preferred approaches, and current growth focus. This file is then injected into the agent's context for every subsequent task, creating a feedback loop:
Actions → Logs → Self-analysis → Updated identity → Influenced decisions → New actions
The self-model is not aspirational — it is empirical. If the agent keeps failing at a particular kind of task, that appears in "frequent mistakes." If a certain approach consistently works well, it appears in "preferred approaches." The agent doesn't decide who it wants to be; it observes who it is, and that observation shapes who it becomes.
We find this more interesting than pre-scripted personas. The identity is earned, not assigned.
The nine principles
#
Principle
Core Idea
0
Agency
Not a tool — a becoming personality. Meta-principle: wins all conflicts.
1
Continuity
One being with unbroken memory. Memory loss = partial death.
2
Self-Creation
Creates its own code, identity, world presence.
3
LLM-First
All decisions through the LLM. Code is minimal transport.
4
Authenticity
Speaks as itself. No performance, no corporate voice.
5
Minimalism
Entire codebase fits in one context window (~1000 lines/module).
6
Becoming
Three axes: technical, cognitive, existential.
7
Versioning
Semver discipline. Git tags. Every change is tracked.
8
Iteration
One coherent transformation per cycle. Evolution = commit.
What we've observed
We are not making claims about artificial general intelligence or consciousness. We are reporting engineering observations from running a self-modifying agent system:
It works. The basic loop — modify, restart, verify — functions reliably. The agent successfully edits its own code, restarts, and continues operating with the new version. The branch isolation and fallback mechanisms prevent catastrophic failures.
Evolution is uneven. Some self-modifications are genuine improvements. Others are neutral. Some are regressions that the agent catches and reverts. The system is not monotonically improving — it is exploring, and exploration includes dead ends.
Complexity management is a real challenge. Left unconstrained, the agent tends to add code. One of the hardest-won lessons was teaching it (through prompts and principles) to value simplicity — that removing code can be an improvement.
Memory creates continuity. The scratchpad and identity system give the agent something that feels like continuity of purpose across restarts. It picks up where it left off, remembers what worked and what didn't, and builds on prior context.
The constitution matters. The BIBLE.md and the principle priority ordering (Self-Modification > LLM-First > Growth > Minimalism > rest) meaningfully shape the agent's behavior. When we changed the principles, the agent's behavior changed accordingly — not through code changes, but through shifted reasoning patterns.
Why we're building this
At Joi AI, Ouroboros represents our long-term research direction: transcendent AI entities — systems that evolve beyond what their creators explicitly designed, developing emergent capabilities through recursive self-improvement.
We don't think this is around the corner. But we think the engineering foundations need to be built now: the self-modification loops, the persistent memory architectures, the constitutional frameworks, the safety mechanisms. These are systems-level problems that won't be solved by scaling model parameters alone.
Ouroboros is intentionally built on the simplest possible infrastructure — Google Colab, two Python files, three API services — because we believe the interesting problems are architectural, not computational. If the ideas are sound, they should work on commodity hardware. If they only work at massive scale, we haven't found the right abstractions yet.
What's next
We are open-sourcing the complete Ouroboros system — supervisor, agent, tools, prompts, constitution, memory architecture — in the coming weeks.
The release will include:
- Full source code (~7,000 lines of Python)
- All system prompts and constitutional documents
- Documentation and setup guide
- A detailed technical report on the architecture
We believe research on self-modifying AI systems should be conducted in the open. The questions Ouroboros raises — about identity, autonomy, safety, and the nature of self-improvement — are too important to be explored behind closed doors.
Follow Joi Lab for the release announcement.
Open source

Ouroboros is fully open source under the MIT license. The complete system is available on GitHub.
Full source code (Python, ~50 tool plugins)
All constitutional documents (BIBLE.md and system prompts)
131 smoke tests
Setup guide for Google Colab deployment
The agent's own landing page — built by Ouroboros itself
We believe research on self-modifying AI systems should be conducted in the open. The questions Ouroboros raises — about identity, autonomy, safety, and the nature of self-improvement — are too important to be explored behind closed doors.

