Legion - Elixir runtime for AI agents

Hey! At Software Mansion we’ve just released Legion, a library that puts AI agents inside your Elixir app, and we’d love to hear what you think.

Agents can build custom views, answer questions about your app, or act on users behalf - in whatever mix suits you.

Instead of a long intro, here’s a video showing Legion in action:

defmodule MyApp.Tools.PostsTool do
  use Legion.Tool

  def get_my_posts do
    %{id: user_id} = Vault.get(:current_user)
    Repo.all(from p in Post, where: p.user_id == ^user_id)
  end
end

defmodule MyApp.PostsAgent do
  @moduledoc "Answers questions about the user's posts."
  use Legion.Agent
  def tools, do: [MyApp.Tools.PostsTool]
end

Vault.init(current_user: %{id: user.id})
Legion.execute(MyApp.PostsAgent, "Summarize my posts from today")

Features TL;DR:

  • Elixir modules as tools
  • Agents as processes
  • Agents write code that runs in a Lua (or Elixir) sandbox - the only way out is the tools you registered
  • Agents can orchestrate other agents
  • Persistence, rate-limiting, and authorization built-in

Play with the demo:

Give us a star on Github:

And read more about what Legion can and can’t do:

Happy to answer questions!

7 Likes