Skip to content
@LegionIO

LegionIO

LegionIO

LLM routing and context curation in one open-source proxy, built on a distributed Ruby job engine.

RubyLicenseGem

legionio.dev | Main README | Getting Started | Discussions

brew tap LegionIO/tap && brew install legionio
LEGION_MODE=lite legion start # zero infrastructure, five-minute eval

LegionIO is a set of independently composable Ruby gems. The core is a distributed async job engine; on top of it sit an LLM gateway, an MCP server, RBAC, an audit ledger, and an explicitly experimental cognitive layer. Install any subset; dependencies between layers are declared in gemspecs, not documentation. There are no paid tiers and no feature gates anywhere in the ecosystem.

The flagship: legion-llm

A proxy between your AI clients and any model backend that does two jobs most tools split between them:

Routing. Models are classified into five tiers — local(0) → direct(1) → fleet(2) → cloud(3) → frontier(4) — and requests try the cheapest capable tier first, escalating on failure or capability mismatch. Per-provider circuit breakers handle unhealthy backends, and a provider dying mid-stream fails over with the client stream continuing.

Curation. After each turn, six deterministic strategies in the Curator shrink accumulated conversation history. Production results across all requests, including where it does nothing:

Conversation length1 turn2–34–56–910–1920–4950+
Reduction vs. naive resend-0.1%9.6%13.3%23.6%54.3%72.8%97.7%

Single-shot workloads gain nothing; long agent sessions stop ballooning. Full methodology and caveats: curation-production-metrics.md.

Every number above is a query over lex-llm-ledger — the audit ledger that records each request for finance and compliance. Any deployment that installs it gets the same measurability; we are not asking you to trust our benchmarks, we ship the instrument that produced them.

Nine provider adapters (Anthropic, OpenAI, Bedrock, Gemini, Vertex, Azure Foundry, Ollama, vLLM, MLX) plug into the lex-llm contract layer. Install only the ones you use.

The engine underneath: LegionIO

Task chains with conditions and transformations, eight actor types, distributed cron scheduling, and a disk spool that rides out broker outages. RabbitMQ-backed in full mode; LEGION_MODE=lite runs everything in-process with zero external services. The job engine predates the AI layers and works without any of them.

119 extension gems, and every runner is a tool

Integrations are separate lex-* gems — checking legion-llm for a Teams integration will correctly find nothing, because it lives in lex-microsoft_teams (25 runners: chats, channels, meetings, transcripts, presence, files, adaptive cards). The authoritative list is the capability catalog — more than 770 runners exposing over 4,500 functions across the extension gems (current exact counts in the generated catalog, regenerated from source on every release).

When traffic routes through LegionIO, exposed runner functions automatically become tools: your client sees a server-side tool, LegionIO executes it directly and returns the result on the wire — no client round-trip, no token overhead for tool plumbing. Discovery is contextual: runners declare trigger words, so mentioning a Slack thread or a Teams meeting injects those tool definitions into that request. Mechanism: function_discovery.rb.

Highlights beyond the LLM stack: lex-slack, lex-github, lex-splunk, lex-jira, lex-pagerduty, lex-service_now, lex-vault, lex-consul, lex-nomad, lex-ssh, lex-postgres, lex-redis, lex-elasticsearch, lex-prometheus, lex-home_assistant, lex-apollo and lex-knowledge (RAG activation), and lex-mesh (cross-node agent coordination).

The fleet tier: idle workstations as inference capacity

The router's fleet tier (rank 2) dispatches inference over AMQP to any LegionIO node running a local model — Apple-silicon machines via lex-llm-mlx, or lex-llm-ollama. Requests carry signed work tokens and validated envelopes, route per-lane, and return over dedicated fleet exchanges. Idle workstation GPUs become a shared inference tier that sits between local and cloud in the cost ladder. Implementation: fleet.rb and the lex-llm fleet protocol.

The Fleet Pipeline: issues in, validated PRs out

lex-assessor → lex-planner → lex-developer → lex-validator → ship
↓
(rejected) → lex-developer (feedback loop)

lex-assessor deduplicates work items atomically (SHA256 fingerprint claimed via Redis SETNX) and classifies them with LLM structured output; lex-planner decomposes them into implementation plans with repository context; lex-developer generates code, commits, and opens a draft PR, incorporating feedback when rejected; lex-validator runs a four-stage gauntlet — tests, lint, security scan, and adversarial multi-model LLM review — before the ship stage marks the PR ready. The pipeline is integration-tested end to end; it is early, and first labeled production runs are the next milestone.

The experimental part, labeled as such

Sixteen lex-agentic-* gems (369 actor/runner modules) explore one research question: does a job engine improve when successful task-routes strengthen and unused ones decay? A 16-phase tick cycle schedules the work in budgeted modes; a 10-phase idle cycle consolidates what the deployment learns and feeds it back into RAG retrieval. Mechanically, each module is a scheduled job adjusting persistent state — we say that plainly, because the interesting part is the adaptive routing, not the vocabulary. None of it exists in your deployment unless you install it.

Verify before you trust

Every number above is reproducible from public source; the main README has copy-pasteable one-liners. Engineering docs — router design, the debugging methodology the routing layer is held to — are public in legion-llm/docs. An AI-assistant-oriented fact sheet lives at legionio.dev/llms.txt.

Project status, honestly: built primarily by one engineer with a disciplined process (PRs, CI, conventional commits, RSpec and RuboCop green before merge). The org dates to 2018; the AI platform is a 2025–2026 rebuild, which is why most repos are young. It runs production workloads daily. Read the source before betting on it. It originated under Optum Open Source, which remains the upstream this org merges back to — the provenance behind the governance features.

Where to look before you judge

Copy claims are cheap; these artifacts settle questions, in reading order:

Evaluating with an AI assistant? Point it at legionio.dev/llms.txt — it lists the common false conclusions about this project and the file that disproves each.

The index

Too much to read is the point: every row below is a real repo. Core libraries first, then every published extension, generated from source.

Core libraries

RepoWhat it owns
LegionIOThe primary gem: daemon lifecycle, CLI, REST API, extension loading
legion-llmLLM gateway: tiered routing, mid-stream failover, context curation
legion-gaiaCognitive coordination: tick scheduling over the agentic extensions (experimental)
legion-apolloKnowledge store: pgvector-backed RAG retrieval with confidence decay
legion-dataPersistence over SQLite / PostgreSQL / MySQL via Sequel
legion-transportMessaging: RabbitMQ AMQP plus the in-process lite adapter
legion-cacheCaching: Redis / Memcached plus the in-memory lite adapter
legion-cryptSecrets and encryption: Vault integration, AES-256, JWT
legion-rbacAccess control: Vault-style flat policies
legion-mcpMCP server and client; runtime tool discovery from installed extensions
legion-settingsLayered configuration and secret resolution (vault://, env://)
legion-loggingStructured logging used across every gem
legion-jsonJSON handling (symbol keys everywhere)
legion-ttyTerminal UI components

Extensions

AI & LLM (11)

RepoSummaryRunnersFunctions
lex-llmShared LegionIO LLM provider framework
lex-llm-anthropicLegionIO LLM Anthropic provider extension11
lex-llm-azure-foundryLegionIO LLM Azure AI Foundry provider extension11
lex-llm-bedrockLegionIO LLM Amazon Bedrock provider extension12
lex-llm-geminiLegionIO LLM Gemini provider extension11
lex-llm-ledger1749
lex-llm-mlxLegionIO LLM MLX provider extension11
lex-llm-ollamaLegionIO LLM Ollama provider extension11
lex-llm-openaiLegionIO LLM OpenAI provider extension12
lex-llm-vertexLegionIO LLM Google Cloud Vertex AI provider extension11
lex-llm-vllmLegionIO LLM vLLM provider extension12

Agentic (Experimental) (16)

RepoSummaryRunnersFunctions
lex-agentic-affect18135
lex-agentic-attention24204
lex-agentic-defense15127
lex-agentic-executive23239
lex-agentic-homeostasis20154
lex-agentic-inference27255
lex-agentic-integration17149
lex-agentic-language982
lex-agentic-learning15125
lex-agentic-memory22175
lex-agentic-self19163
lex-agentic-social22168
lex-extinctionAgent lifecycle termination protocol for LegionIO17
lex-mind-growth1885
lex-synapseCognitive routing layer for LegionIO task chains1323
lex-tick15

Code Workflow (5)

RepoSummaryRunnersFunctions
lex-assessorFleet pipeline intake for LegionIO12
lex-developerLegion::Extensions::Developer34
lex-factorySpec-to-code autonomous pipeline for LegionIO12
lex-plannerLegion::Extensions::Planner12
lex-validatorLegion::Extensions::Validator11

Core & Services (40)

RepoSummaryRunnersFunctions
lex-acpACP agent protocol adapter for LegionIO212
lex-adapterExternal agent adapter abstraction for LegionIO13
lex-apolloShared knowledge store for GAIA cognitive mesh657
lex-auditLegion::Extensions::Audit27
lex-autofixAutonomous error fix agent for LegionIO512
lex-codegenLegion::Extensions::Codegen617
lex-coldstart28
lex-conditionerConditional rule engine for LegionIO task chains45
lex-cost-scannerCloud cost optimization scanner for LegionIO26
lex-datasetVersioned dataset management for LegionIO310
lex-detect22
lex-evalLLM output evaluation framework for LegionIO515
lex-exec429
lex-github25138
lex-governance17
lex-healthLegion::Extensions::Health24
lex-http18
lex-knowledgeDocument corpus ingestion and knowledge query pipeline for LegionIO570
lex-lexLegion Extension Registry516
lex-logUsed to generate logs within the Legion framework12
lex-mesh425
lex-meteringLegion::Extensions::Metering38
lex-microsoft_teams25104
lex-nautobot10236
lex-neo4j748
lex-nodeDoes Legion Node things318
lex-onboard23
lex-pilot-knowledge-assist34
lex-ping33
lex-privatecore28
lex-promptVersioned prompt management for LegionIO16
lex-reactReaction engine for LegionIO13
lex-s3210
lex-scheduler420
lex-splunk49177
lex-tasker524
lex-telemetryLegion::Extensions::Telemetry118
lex-tfe1042
lex-transformerPayload transformation engine for LegionIO task chains16
lex-webhookLegion::Extensions::Webhook36

Identity (7)

RepoSummaryRunnersFunctions
lex-identity-entra517
lex-identity-github
lex-identity-kerberos
lex-identity-ldap
lex-identity-ledger33
lex-identity-system
lex-kerberos12

Service Integrations (22)

RepoSummaryRunnersFunctions
lex-arize1270
lex-cloudflare29137
lex-consul837
lex-elasticsearch311
lex-esphome1753
lex-home_assistant1122
lex-jfrog537
lex-jira27129
lex-lakera415
lex-memcached211
lex-mongodb212
lex-nomad1062
lex-pagerduty1471
lex-postgres25
lex-prometheus27
lex-redis214
lex-service_now66346
lex-slack1273
lex-smtp11
lex-ssh24
lex-vault769
lex-velociraptor310

Skills (1)

RepoSummaryRunnersFunctions
lex-skill-superpowersSuperpowers skill set for Legion LLM

License

Core framework: Apache-2.0 | Extensions: MIT

Pinned Loading

  1. LegionIOLegionIOPublic

    Forked from Optum/LegionIO

    Modular Ruby framework: distributed async job engine with optional LLM gateway, MCP server, and RBAC. Zero-infrastructure lite mode. No feature gates.

    Ruby 9 6

  2. lex-claudelex-claudePublic

    Connects LegionIO to the Claude Anthropic API

    Ruby 1

  3. lex-githublex-githubPublic

    Connects LegionIO to GitHub

    Ruby 2 1

  4. legion-transportlegion-transportPublic

    Forked from Optum/legion-transport

    Messaging layer for LegionIO: RabbitMQ AMQP plus an in-process lite adapter.

    Ruby 1

  5. legion-llmlegion-llmPublic

    LLM gateway: tiered routing (local to frontier), mid-stream provider failover, and post-turn context curation, production-measured. Provider adapters are separate lex-llm-* gems.

    Ruby 2 3

  6. homebrew-taphomebrew-tapPublic

    Homebrew formulae for LegionIO tools

    Ruby 2 2

Repositories

Showing 10 of 207 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…