{"slug": "show-hn-legion-ai-agents-that-write-sandboxed-lua-inside-your-elixir-app", "title": "Show HN: Legion – AI agents that write sandboxed Lua inside your Elixir app", "summary": "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.", "body_md": "## Code instead of one-off tool calls\n\nAgents can run vetted Lua (or Elixir) code that composes your tools to achieve things that were impossible before - with near zero configuration.\n\nWe can't find the internet\n\nAttempting to reconnect\n\nSomething went wrong!\n\n      Open source Elixir library created by\n      \n\nLegion is an Elixir runtime for AI agents that live inside your application and get things done by writing code.\n\nIn plain words\n\nInstead 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.\n\nThe 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.\n\nEvery 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.\n\nCapable by default, contained by design.\n\nEvery 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.\n\n`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.\n\nSet 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.\n\nStart 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.\n\nPoint Legion at your Repo and you'll have persistence and rate limiting for your agents.\n\nTelemetry 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.\n\nYou might know us from Elixir Stream Week, Global Elixir Meetups, or from projects like Popcorn and Membrane. But that’s not all we do.\n\nWe help teams build exceptional software - from developer tools to production-ready applications. Let’s talk about how we can support your next project.", "url": "https://wpnews.pro/news/show-hn-legion-ai-agents-that-write-sandboxed-lua-inside-your-elixir-app", "canonical_source": "https://legion.swmansion.com/", "published_at": "2026-09-16 13:23:20+00:00", "updated_at": "2026-09-16 13:44:10.040735+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-products"], "entities": ["Legion", "Elixir", "Lua", "BEAM", "Legion.Tool", "legion_web", "Claude", "Cursor"], "alternates": {"html": "https://wpnews.pro/news/show-hn-legion-ai-agents-that-write-sandboxed-lua-inside-your-elixir-app", "markdown": "https://wpnews.pro/news/show-hn-legion-ai-agents-that-write-sandboxed-lua-inside-your-elixir-app.md", "text": "https://wpnews.pro/news/show-hn-legion-ai-agents-that-write-sandboxed-lua-inside-your-elixir-app.txt", "jsonld": "https://wpnews.pro/news/show-hn-legion-ai-agents-that-write-sandboxed-lua-inside-your-elixir-app.jsonld"}}