Skip to content

oliverpecha/BEO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

BEO โ€” Bureau of External Operations

A self-hosted, multi-tier Telegram AI assistant.
Routes every query through the cheapest viable model tier โ€” semantic cache, live web lookups, headless scraping, and deep synthesis โ€” all on a single 4 GB VPS.

License: MIT Docker


What is BEO?

๐Ÿ“Ÿ BEO (Bureau of Ethereal Operations) is a self-hosted multi-model routing layer built for OpenClaw. Instead of sending every query to one model through a provider with an incentive to maximize your spend, BEO routes each query to the cheapest model that can handle it.

The Official Bureau Cast List

BEO operates via a distinct roster of specialized agents:

  • ๐ŸŽฌ The Director (OpenClaw): The primary orchestration daemon that sits on the local node and autonomously determines operational Tiers.
  • ๐Ÿ”‘ The Gatekeeper (LiteLLM): The API proxy that enforces rate limits, failover logic, and manages promotional keys.
  • ๐ŸŽ™ The MC (Gemini 3 Flash Preview): The sassy front-end voice that processes logic and formats the final broadcast.
  • ๐Ÿ“š The Librarian (Redis): The keeper of the semantic cache that serves identical previous queries instantly.
  • ๐Ÿ’ผ The Broker (Brave Search API): A programmatic search index that trades real-time web snippets for fractions of a cent.
  • ๐Ÿƒ The Minions (Gemini 3.1 Flash-Lite): High-concurrency grunts that execute local parallel scraping and strip CSS/JS.
  • ๐Ÿ”ฎ The Oracle (Gemini 1.5 Pro): A cloud-based model with a 2M-token vision used for deep synthesis of massive payloads.
  • ๐Ÿ›๏ธ The Board (Claude 4.6 Opus): The ultimate authority summoned exclusively via strict keyword rituals for existential overrides.

The Ethereal Triage Protocol

Every inbound message passes through a pre-flight pipeline that enforces a strict escalation ladder:

Tier Name Action Target Cost
0 ๐Ÿง  The Brain Pure Logic: Handled by The MC directly from internal neural weights. ~$0.00007
1 ๐Ÿ—„๏ธ The Cabinet Redis Cache: Instant bypass of LLM generation for identical semantic queries. $0.00
2 ๐Ÿ—‚๏ธ The Desk Quick Facts: Bypasses scraping, pays The Broker directly for a JSON snippet. ~$0.0005
3 ๐Ÿ—บ๏ธ The Field General Browsing: Deploys Minions to locally scrape and strip HTML from specific URLs. ~$0.01
4 ๐ŸŒ€ The Extraction Deep Research: Massive data payloads hoisted to The Oracle for deep synthesis. ~$0.10
5 ๐Ÿ‘‘ The VIP The Board: Bypasses The Director entirely via the /opus trigger. $0.50+

Built on OpenClaw + LiteLLM + Redis + Telegram long-polling. Designed to run on a single lower-tier VPS (2 vCPU, 4 GB RAM).


Architecture

See docs/BLUEPRINT.md for the full engineering spec (BLU-01 โ†’ BLU-33).

Telegram
    โ”‚
    โ–ผ
Pre-flight
โ”œโ”€โ”€ Language detect (lingua, ~1ms, no API call)
โ”œโ”€โ”€ TLD validation (IANA cache)
โ”œโ”€โ”€ URL extraction (1โ€“5 โ†’ Tier 3, 5+ โ†’ Tier 4)
โ”œโ”€โ”€ Slash commands (/opus โ†’ Tier 5)
โ”œโ”€โ”€ Attachment / char count triggers (โ†’ Tier 4)
โ”œโ”€โ”€ Desk keyword match (โ†’ Tier 2, no_store=true)
โ””โ”€โ”€ Nano-classifier fallback (Flash Lite โ†’ Tier 1 or 2)
    โ”‚
    โ–ผ
Redis Semantic Cache โ”€โ”€ Tier 0
โ”œโ”€โ”€ Embedding: text-embedding-004
โ”œโ”€โ”€ Similarity threshold: 0.92
โ”œโ”€โ”€ Cache HIT  โ”€โ”€โ–บ return immediately (no LLM call, no cost)
โ””โ”€โ”€ Cache MISS โ”€โ”€โ–บ continue
    โ”‚
    โ–ผ
LiteLLM Gateway
โ”œโ”€โ”€ Budget enforcement (per-key max_budget, SQLite)
โ”œโ”€โ”€ Key rotation (Gemini promo pool, simple-shuffle / least-busy)
โ”œโ”€โ”€ Per-tier timeouts
โ””โ”€โ”€ Semantic cache write (no_store flag from pre-flight)
    โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ–ผ                 โ–ผ                  โ–ผ                  โ–ผ                 โ–ผ
Tier 1            Tier 2             Tier 3             Tier 4            Tier 5
The Brain         The Desk           The Field          The Extraction    The VIP
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€         โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€           โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€          โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€    โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Flash Pro         Flash Pro          Flash Lite         Flash Pro         Opus / top
                  + The Broker       + The Minions      + The Oracle      capability
    โ”‚             (mcp-search        (1 sub-agent       (multi-source     model
    โ”‚             live lookup)       per URL,           synthesis,
    โ”‚                                mcp-firecrawl      structured            โ”‚
    โ”‚                 โ”‚              JS fallback)       memo output)          โ”‚
    โ”‚                 โ”‚              โ”‚                      โ”‚                 โ”‚
    โ”‚                 โ”‚             token overflow?         โ”‚                 โ”‚
    โ”‚                 โ”‚             (>8k tokens)            โ”‚                 โ”‚
    โ”‚                 โ”‚              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ”‚
    โ”‚                 โ”‚                       โ”‚                               โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                              โ”‚
                                              โ–ผ
                                          The MC
                                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                  โ”‚ Tier 1: generate   โ”‚
                                  โ”‚ Tier 2โ€“5: railblockโ”‚
                                  โ”‚ (format + deliver  โ”‚
                                  โ”‚  only, no re-      โ”‚
                                  โ”‚  synthesis)        โ”‚
                                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                              โ”‚
                               Runtime Redirection (if needed)
                               โ”œโ”€โ”€ live fact detected  โ†’ Tier 2
                               โ”œโ”€โ”€ URLs found mid-turn โ†’ Tier 3
                               โ””โ”€โ”€ massive payload     โ†’ Tier 4
                                              โ”‚
                                              โ–ผ
                                          Telegram
                                    (response delivered)

Prerequisites


Quick Start

# 1. Clone
git clone https://github.com/YOUR_USERNAME/beo.git && cd beo

# 2. Bootstrap โ€” creates required host dirs and copies .env.example
./setup.sh

# 3. Fill in your keys
nano .env

# 4. Copy and adjust OpenClaw config
cp openclaw.json.example openclaw.json

# 5. Launch
docker compose up -d

# 6. Check logs
docker compose logs -f

Why setup.sh? Git cannot track empty directories. data/redis/ must exist on the host before Docker mounts it โ€” otherwise Docker creates it as root and Redis fails to write. setup.sh creates it with correct ownership. Run it once after every fresh clone.


Configuration

All configuration lives in three files:

File Purpose
.env API keys and operational thresholds (never committed)
litellm_config.yaml Model aliases, budgets, router strategy, semantic cache
openclaw.json Agent definitions, approval policy, compaction settings

See .env.example for all required variables with inline documentation.


Deployment

BEO is designed for a single-node VPS. The deploy workflow is:

# On your VPS โ€” after git clone and .env setup
docker compose up -d

# To update after a git push
git pull origin main && docker compose up -d --no-build

See docs/DEPLOY.md for the full VPS setup walkthrough.


Roadmap

See docs/ROADMAP.md for the phased deployment roadmap (Phase 0 โ†’ Phase 6).


License

MIT โ€” see LICENSE.

About

๐Ÿ“Ÿ BEO (Bureau of Ethereal Operations) is a self-hosted multi-model routing layer built for OpenClaw. Instead of sending every query to one model through a provider with an incentive to maximize your spend, BEO routes each query to the cheapest model that can handle it.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors