Legion

AI agents that write sandboxed Lua inside your Elixir app

Working when we checked on .

Visit Legion

What is Legion?

Legion is an open source Elixir runtime that lets AI agents live inside an application and get things done by writing code. It is aimed at Elixir developers and teams building apps that need agents which can find records, run reports, change settings, or file tickets. Agents run vetted Lua or Elixir code to compose tools, with every evaluation sandboxed under timeout, memory, and CPU budgets. It includes persistence and rate limiting via Postgres, per-user auth scoping, and a LiveView dashboard with telemetry for observability. The same agent can power a chat window, an MCP server for Claude or Cursor, or a background worker.

Legion pricing

Pricing model: Free

Open source (free)

Legion pros

  • Open source library created by Software Mansion, with GitHub contribution available
  • Agents execute vetted Lua or Elixir code composing tools with near zero configuration
  • Every evaluation is sandboxed with timeout, memory, and CPU budgets
  • Tools are plain modules via `use Legion.Tool`; agent reads source and calls functions directly
  • Persistence and rate limiting backed by your own Postgres repo
  • Telemetry at agent, message, iteration, LLM call and sandbox levels plus LiveView dashboard

Legion cons

  • Requires an Elixir/BEAM application; not usable outside the Elixir ecosystem
  • Lua sandbox cannot reach the host BEAM; only registered tools are exposed
  • Pricing plans and commercial support details are not documented on the page

Frequently asked questions about Legion

What is Legion?

Legion is an open source Elixir runtime for AI agents that live inside an application and get things done by writing code. It was created by Software Mansion.

Who is Legion for?

It is aimed at Elixir developers and teams who want to embed AI agents in their applications, including products by Software Mansion clients and community projects.

How do agents differ from a chatbot?

Instead of only talking, a Legion agent reaches into the application and acts: it finds records, runs reports, changes settings, and files tickets, using only the functions the developer allows.

In what ways can an agent be deployed?

The same agent can sit behind a chat window, power an MCP server for Claude or Cursor, or run as a background worker that clears a queue overnight. One runtime supports many shapes.

What languages can agents write?

Agents run vetted Lua or Elixir code that composes registered tools, enabling behavior that one-off tool calls cannot achieve, with near zero configuration.

How are agent executions sandboxed?

Every evaluation runs in a monitored process with timeout, memory, and CPU budgets. Lua cannot reach the host BEAM at all; the only way out is through registered tools.

How are tools defined?

Adding `use Legion.Tool` to any module lets the agent read its source and call its functions directly, so there is nothing to define or keep in sync as the app changes.

How does Legion handle user authentication?

Developers set auth context before the agent starts and read it inside tools at runtime. Every call is scoped to that signed-in user, and generated code never sees credentials.

How is data stored?

Point Legion at your Ecto Repo and it uses your Postgres database for conversations, persistence, and rate limiting, so data stays in your own database.

Is Legion free?

Yes, Legion is open source by Software Mansion and can be contributed to on GitHub at github.com/software-mansion/legion. No paid plans are mentioned.

Categories

Use cases

Alternatives to Legion

Similar AI tools

Search AI tools on NeedAnAI · All AI tools A–Z