<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9" -->

---
title: an AI agent inside your Elixir app | daily.dev
description: Legion is an open source Elixir runtime that embeds AI agents directly into applications, letting them act on the app rather than just chat. Agents write...
canonical: https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: an AI agent inside your Elixir app | daily.dev
og:description: Legion is an open source Elixir runtime that embeds AI agents directly into applications, letting them act on the app rather than just chat. Agents write...
og:url: https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9
og:image: https://api.daily.dev/og/posts/jpc6D4im9.png
og:image:alt: an AI agent inside your Elixir app
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# an AI agent inside your Elixir app

**[Awesome Elixir](https://daily.dev/sources/awelix)** · 3 min read · 0 upvotes · 0 comments

## Summary

Legion is an open source Elixir runtime that embeds AI agents directly into applications, letting them act on the app rather than just chat. Agents write vetted Lua or Elixir code to compose registered tools, run in sandboxed BEAM processes with time, memory, and CPU limits, and can power chat interfaces, MCP servers for tools like Claude or Cursor, or background workers. It integrates with Postgres for persistence and rate limiting, scopes actions to the signed-in user, and ships with a LiveView dashboard for observability into agent conversations and generated code. Built by Software Mansion, the team behind Membrane and Popcorn.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://legion.swmansion.com/>

## Questions this post answers

### How does Legion sandbox AI agent code in an Elixir application?

Legion runs every agent code evaluation inside a monitored BEAM process with timeout, memory, and CPU budgets. The generated Lua code cannot reach the host BEAM directly; the only way it can affect the application is through tools explicitly registered by the developer, keeping agent actions contained by design.

_Developers wiring agents into Elixir apps can track sandboxing approaches like this on daily.dev._

### How do I let an AI agent call functions in my Elixir app safely?

With Legion, you mark any module with 'use Legion.Tool' and the agent automatically reads its source and calls its functions directly, without manually defining tool schemas. Access can be scoped to the signed-in user by setting auth context before the agent starts, so generated code never sees credentials.

_Elixir engineers integrating AI agents can follow patterns like this via daily.dev._

## Similar posts on daily.dev

- [GitHub - thatsme/AlexClaw: BEAM-native personal AI agent built on Elixir/OTP. Runs on your hardware. Your data stays yours.](https://daily.dev/posts/github---thatsme-alexclaw-beam-native-personal-ai-agent-built-on-elixir-otp-runs-on-your-hardware--oz0tqjsf2) · ElixirStatus · 1 upvotes · 0 comments
- [Vercel Releases Open Agents to Support Background AI Coding Workflows](https://daily.dev/posts/vercel-releases-open-agents-to-support-background-ai-coding-workflows-rqcak8vwn) · InfoQ · 1 upvotes · 1 comments
- [I just published a course on building agents using Elixir](https://daily.dev/posts/i-just-published-a-course-on-building-agents-using-elixir-af7tq2dth) · Elixir Forum · 1 upvotes · 0 comments
- [AgentsView: A practical look at your AI agent sessions](https://daily.dev/posts/agentsview-a-practical-look-at-your-ai-agent-sessions-k2zkw0xij) · The Art of Simplicity · 1 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#mcp](https://daily.dev/tags/mcp), [#elixir](https://daily.dev/tags/elixir)

[View this post on daily.dev](https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"an AI agent inside your Elixir app","url":"https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9"},"datePublished":"2026-09-17T20:42:36.707Z","dateModified":"2026-09-17T23:00:28.685Z","description":"Legion is an open source Elixir runtime that embeds AI agents directly into applications, letting them act on the app rather than just chat. Agents write...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ecd4857c9810e5a7baff2c89aff29864?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ecd4857c9810e5a7baff2c89aff29864?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Awesome Elixir","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Awesome Elixir","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/85a474f78b1b4d349119f7ce60d1438e","url":"https://daily.dev/sources/awelix"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,mcp,elixir","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Awesome Elixir","item":"https://daily.dev/sources/awelix"},{"@type":"ListItem","position":3,"name":"an AI agent inside your Elixir app"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/an-ai-agent-inside-your-elixir-app-jpc6d4im9#faq","mainEntity":[{"@type":"Question","name":"How does Legion sandbox AI agent code in an Elixir application?","acceptedAnswer":{"@type":"Answer","text":"Legion runs every agent code evaluation inside a monitored BEAM process with timeout, memory, and CPU budgets. The generated Lua code cannot reach the host BEAM directly; the only way it can affect the application is through tools explicitly registered by the developer, keeping agent actions contained by design. Developers wiring agents into Elixir apps can track sandboxing approaches like this on daily.dev."}},{"@type":"Question","name":"How do I let an AI agent call functions in my Elixir app safely?","acceptedAnswer":{"@type":"Answer","text":"With Legion, you mark any module with 'use Legion.Tool' and the agent automatically reads its source and calls its functions directly, without manually defining tool schemas. Access can be scoped to the signed-in user by setting auth context before the agent starts, so generated code never sees credentials. Elixir engineers integrating AI agents can follow patterns like this via daily.dev."}}]}
```

