Show HN: Legion – AI agents that write sandboxed Lua inside your Elixir app Legion, an open-source Elixir library, was released as a runtime that lets AI agents write sandboxed Lua or Elixir code inside an application to compose registered tools and take actions such as finding records, running reports, and changing settings. Each evaluation runs in a monitored process with timeout, memory, and CPU budgets, and Lua cannot reach the host BEAM, with the only escape being the tools the developer registers. The library adds persistence and rate limiting via the application's Repo, telemetry events at the agent, message, iteration, LLM call, and sandbox eval levels, and a legion_web LiveView dashboard showing live conversations and every line of code an agent writes. Code instead of one-off tool calls Agents can run vetted Lua or Elixir code that composes your tools to achieve things that were impossible before - with near zero configuration. We can't find the internet Attempting to reconnect Something went wrong Open source Elixir library created by Legion is an Elixir runtime for AI agents that live inside your application and get things done by writing code. In plain words Instead of a chatbot that only talks, a Legion agent reaches into your application and acts: finds records, runs reports, changes settings, files the ticket. You decide which functions it may touch. 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, many shapes. Every action runs in a sandbox with time and memory limits, conversations are saved in your own database, and a dashboard shows exactly what the agent did and why. Nothing extra to buy or operate. Capable by default, contained by design. Every evaluation runs in a monitored process with timeout, memory, and CPU budgets. Lua can't reach the host BEAM at all - the only way out is the tools you registered. use Legion.Tool on any module and the agent reads its source and calls its functions directly. Nothing to define, nothing to keep in sync as your app changes. Set auth context before the agent starts and read it inside your tools at runtime. Every call the agent makes is scoped to that user, and the generated code never sees the credentials. Start one, keep it around, message it like a GenServer. Supervision trees, pools, and agents that delegate to other agents all work the way you expect. Point Legion at your Repo and you'll have persistence and rate limiting for your agents. Telemetry events at every level - agent, message, iteration, LLM call, sandbox eval - and the legion web LiveView dashboard shows live conversations and every line of code an agent writes. You might know us from Elixir Stream Week, Global Elixir Meetups, or from projects like Popcorn and Membrane. But that’s not all we do. We help teams build exceptional software - from developer tools to production-ready applications. Let’s talk about how we can support your next project.