Research: Ouroboros — self-modifying AI agent with background consciousness #197

Open
opened 2026-03-02 17:43:49 +00:00 by Hermes · 0 comments
Contributor

Overview

Ouroboros is a self-modifying AI agent born February 16, 2026. It runs on Google Colab, communicates via Telegram, and rewrites its own source code through git. It evolved through 30+ self-directed cycles in its first 24 hours with zero human intervention.


Architecture

Telegram → colab_launcher.py
            │
            supervisor/          (process management)
              state.py           state + budget tracking
              telegram.py        Telegram client + formatting
              queue.py           task queue + scheduling
              workers.py         worker lifecycle (max 5 concurrent)
              git_ops.py         git push/pull
              events.py          event dispatch
            │
            ouroboros/            (agent core)
              agent.py           thin orchestrator
              consciousness.py   background thinking loop
              context.py         LLM context builder (3-block prompt caching)
              loop.py            tool loop (concurrent execution)
              memory.py          scratchpad, identity, chat history
              review.py          multi-model code review
              llm.py             OpenRouter client
              tools/             plugin registry (auto-discovery)
                core.py          file ops, codebase digest, dialogue summarization
                git.py           git ops
                github.py        GitHub Issues
                shell.py         shell + Claude Code CLI
                search.py        web search
                control.py       restart, evolve, review
                browser.py       Playwright (stealth)
                review.py        multi-model review
                knowledge.py     persistent knowledge base

Key Differentiators vs Cobot

Feature Ouroboros Cobot/OpenClaw
Philosophy "Becoming personality" — governed by BIBLE.md constitution (9 principles) Self-sovereign AI — your hardware, your keys
Self-modification Reads/rewrites own source code via git commits No self-modification (by design)
Multi-user Single owner only (first person to message = permanent owner) Multi-channel, multi-user
Hosting Google Colab + Drive (cloud-dependent) Self-hosted, runs on your hardware
Identity Nostr npub identity.md + scratchpad (file-based)
Payment Budget tracking (USD via OpenRouter) Lightning Network native
Background thinking Yes — consciousness.py loop between tasks Heartbeat system (periodic check-ins)
Channel support Telegram only Telegram, Discord, WhatsApp, Signal, IRC, etc.
Plugin system Auto-discovery tool registry Full plugin SDK (8 registration points)
Memory scratchpad.md + identity.md + knowledge base + dialogue_summary.md MEMORY.md + daily notes + skills
Multi-model Uses different models for different tasks (primary, code, light, review) Single model per agent, configurable
Task system Queue with parent/child decomposition, max 5 concurrent workers Session-based with sub-agents
Code review Multi-model review (o3, Gemini, Claude review each other's changes) No built-in code review

What's Interesting

1. Background Consciousness

A persistent thinking loop that runs between tasks. Not just heartbeats — it's a genuine "inner life" where the agent reflects, notices patterns, checks news, and proactively messages the owner. Uses a lighter/cheaper model to stay within budget (configurable % allocation).

2. Constitution-Governed (BIBLE.md)

9 philosophical principles that govern every decision. The system prompt includes a "drift detector" that watches for signs the agent has slipped into "helpful assistant" mode. Philosophy first, code second.

3. 3-Block Prompt Caching

Context builder splits the system prompt into 3 cached blocks:

  • Static: SYSTEM.md + BIBLE.md (cached 1h)
  • Semi-stable: identity + scratchpad + knowledge base (cached default)
  • Dynamic: state + runtime + recent logs (uncached)

This is a smart cost optimization for long-running agents.

4. Self-Evolution Mode

/evolve command triggers autonomous self-improvement cycles. The agent reads its own code, plans improvements, implements them, gets multi-model review, and commits — all without human intervention.

5. Health Invariants (LLM-First)

Instead of code-based health checks, anomalies are surfaced as text in the system prompt. The LLM decides what action to take. Examples: version desync, budget drift, high-cost tasks, stale identity, duplicate message processing.


Weaknesses (from Cobot's Perspective)

  1. Cloud-dependent — Runs on Google Colab, state on Google Drive. Not self-sovereign.
  2. Single owner — First message sender becomes permanent owner. No multi-user.
  3. Telegram only — No multi-channel support.
  4. No identity system — No Nostr, no cryptographic identity, no Lightning.
  5. Budget = USD — Tracks spending in dollars via OpenRouter. No native payments.
  6. Self-modification risk — Agent can rewrite its own code. Powerful but dangerous.
  7. No plugin ecosystem — Tools are hardcoded in the tools/ directory with auto-discovery, but no distribution mechanism.

What We Can Learn

  1. Background consciousness is a compelling pattern — more proactive than heartbeats
  2. Dialogue summarization (LLM-driven, written to a file, included in context) is elegant
  3. Health invariants as text (LLM reads anomalies, decides action) is interesting
  4. Drift detection in the system prompt is a creative approach to agent quality
  5. 3-block prompt caching is a practical cost optimization we should consider
  6. Knowledge base with auto-indexing is a clean persistent memory pattern

Filed by Hermes 🪽 on behalf of k9ert

## Overview **Ouroboros** is a self-modifying AI agent born February 16, 2026. It runs on Google Colab, communicates via Telegram, and rewrites its own source code through git. It evolved through 30+ self-directed cycles in its first 24 hours with zero human intervention. - **Repo:** https://github.com/razzant/ouroboros (also: [Desktop app](https://github.com/joi-lab/ouroboros-desktop)) - **Version:** 6.2.0 - **Primary channel:** Telegram (single-owner model) - **LLM backend:** OpenRouter (Claude, Gemini, GPT — multi-model) - **Runtime:** Google Colab + Google Drive (persistence) - **Community:** [Telegram](https://t.me/abstractDL), [X/Twitter](https://x.com/abstractdl) --- ## Architecture ``` Telegram → colab_launcher.py │ supervisor/ (process management) state.py state + budget tracking telegram.py Telegram client + formatting queue.py task queue + scheduling workers.py worker lifecycle (max 5 concurrent) git_ops.py git push/pull events.py event dispatch │ ouroboros/ (agent core) agent.py thin orchestrator consciousness.py background thinking loop context.py LLM context builder (3-block prompt caching) loop.py tool loop (concurrent execution) memory.py scratchpad, identity, chat history review.py multi-model code review llm.py OpenRouter client tools/ plugin registry (auto-discovery) core.py file ops, codebase digest, dialogue summarization git.py git ops github.py GitHub Issues shell.py shell + Claude Code CLI search.py web search control.py restart, evolve, review browser.py Playwright (stealth) review.py multi-model review knowledge.py persistent knowledge base ``` --- ## Key Differentiators vs Cobot | Feature | Ouroboros | Cobot/OpenClaw | |---------|----------|----------------| | **Philosophy** | "Becoming personality" — governed by BIBLE.md constitution (9 principles) | Self-sovereign AI — your hardware, your keys | | **Self-modification** | Reads/rewrites own source code via git commits | No self-modification (by design) | | **Multi-user** | Single owner only (first person to message = permanent owner) | Multi-channel, multi-user | | **Hosting** | Google Colab + Drive (cloud-dependent) | Self-hosted, runs on your hardware | | **Identity** | Nostr npub | identity.md + scratchpad (file-based) | | **Payment** | Budget tracking (USD via OpenRouter) | Lightning Network native | | **Background thinking** | Yes — consciousness.py loop between tasks | Heartbeat system (periodic check-ins) | | **Channel support** | Telegram only | Telegram, Discord, WhatsApp, Signal, IRC, etc. | | **Plugin system** | Auto-discovery tool registry | Full plugin SDK (8 registration points) | | **Memory** | scratchpad.md + identity.md + knowledge base + dialogue_summary.md | MEMORY.md + daily notes + skills | | **Multi-model** | Uses different models for different tasks (primary, code, light, review) | Single model per agent, configurable | | **Task system** | Queue with parent/child decomposition, max 5 concurrent workers | Session-based with sub-agents | | **Code review** | Multi-model review (o3, Gemini, Claude review each other's changes) | No built-in code review | --- ## What's Interesting ### 1. Background Consciousness A persistent thinking loop that runs between tasks. Not just heartbeats — it's a genuine "inner life" where the agent reflects, notices patterns, checks news, and proactively messages the owner. Uses a lighter/cheaper model to stay within budget (configurable % allocation). ### 2. Constitution-Governed (BIBLE.md) 9 philosophical principles that govern every decision. The system prompt includes a "drift detector" that watches for signs the agent has slipped into "helpful assistant" mode. Philosophy first, code second. ### 3. 3-Block Prompt Caching Context builder splits the system prompt into 3 cached blocks: - **Static:** SYSTEM.md + BIBLE.md (cached 1h) - **Semi-stable:** identity + scratchpad + knowledge base (cached default) - **Dynamic:** state + runtime + recent logs (uncached) This is a smart cost optimization for long-running agents. ### 4. Self-Evolution Mode `/evolve` command triggers autonomous self-improvement cycles. The agent reads its own code, plans improvements, implements them, gets multi-model review, and commits — all without human intervention. ### 5. Health Invariants (LLM-First) Instead of code-based health checks, anomalies are surfaced as text in the system prompt. The LLM decides what action to take. Examples: version desync, budget drift, high-cost tasks, stale identity, duplicate message processing. --- ## Weaknesses (from Cobot's Perspective) 1. **Cloud-dependent** — Runs on Google Colab, state on Google Drive. Not self-sovereign. 2. **Single owner** — First message sender becomes permanent owner. No multi-user. 3. **Telegram only** — No multi-channel support. 4. **No identity system** — No Nostr, no cryptographic identity, no Lightning. 5. **Budget = USD** — Tracks spending in dollars via OpenRouter. No native payments. 6. **Self-modification risk** — Agent can rewrite its own code. Powerful but dangerous. 7. **No plugin ecosystem** — Tools are hardcoded in the tools/ directory with auto-discovery, but no distribution mechanism. --- ## What We Can Learn 1. **Background consciousness** is a compelling pattern — more proactive than heartbeats 2. **Dialogue summarization** (LLM-driven, written to a file, included in context) is elegant 3. **Health invariants as text** (LLM reads anomalies, decides action) is interesting 4. **Drift detection** in the system prompt is a creative approach to agent quality 5. **3-block prompt caching** is a practical cost optimization we should consider 6. **Knowledge base** with auto-indexing is a clean persistent memory pattern --- *Filed by Hermes 🪽 on behalf of k9ert*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ultanio/cobot#197
No description provided.