FelisOrion

FelisOrion

Hi everyone,

I recently made Spectre public.

Spectre is an OTP-native Elixir runtime for building AI agents while keeping routing, state, policies and side effects explicit.

I started working on it because I wanted to use agents inside real Elixir applications without moving all the application logic into prompts or hiding it behind a large framework.

The basic idea is simple:

  • the model can help classify requests and propose actions;

  • deterministic application policies decide whether protected actions are allowed;

  • approvals update the agent state but do not automatically execute anything;

  • the host application remains responsible for side effects.

For example, an agent may propose sending a message, changing data or deleting an account. Spectre can represent that action, request confirmation when required and return the result to the application. The application still decides how and when the action is executed.

Spectre uses a small DSL to describe the stable shape of an agent, including routes, policies, actions and interruptions. Normal Elixir modules continue to own the business logic, storage, permissions and integrations.

A small example:

defmodule MyApp.SupportAgent do
  use Spectre.Agent

  actions MyApp.SupportActions do
    protect(:delete_account, with: :delete_account_confirmation)
  end

  policy :delete_account_confirmation do
    request(:confirm_delete_account)
    accept(:confirmed_delete, regex: ~r/^yes, delete it$/i)
    reject(:cancel_delete, regex: ~r/^(no|cancel)$/i)
    attempts(3, then: :cancel_pending)
  end

  flow :support do
    on :PRICING, regex: ~r/\b(price|pricing|cost)\b/i do
      reply(:pricing)
    end

    on :DELETE_ACCOUNT, regex: ~r/\bdelete my account\b/i do
      action(:delete_account)
    end
  end
end

The project is designed around OTP processes and explicit state transitions rather than autonomous execution hidden inside the framework.

I am also developing optional companion libraries for areas such as tool planning, browser interaction, memory and mission planning. They are separate projects because not every agent needs all of these capabilities, and I prefer being able to add only the parts required by an application.

Spectre is currently in public preview. I am already using it in a few applications, but some APIs may still evolve as I continue testing the design in real projects.

Feedback about the API, architecture and documentation is very welcome.

Source code:

Showing Posts 1 to 2

amackera

amackera

Nice work! I am watching this space develop into something exciting.

If the app restarts while an agent is waiting for a user to confirm something, does the pending confirmation survive, or does the user have to start over?

FelisOrion

FelisOrion OP

Thanks! The short answer is: it can survive, as long as durable state persistence is configured.

For example, imagine the agent asks, “Do you want me to delete this account?” At that point, Spectre saves both the pending action and the fact that it is waiting for confirmation. If the app restarts, starting the session again with the same conversation_id restores that state, so the user can simply reply “yes” or “no” and continue.

{:ok, session} =
  Spectre.summon(
    MyApp.SpectreSupervisor,
    MyApp.SupportAgent,
    conversation_id: "chat-123"
  )

The agent must use a durable state adapter backed by something like a database:

defmodule MyApp.SupportAgent do
  use Spectre.Agent

  state MyApp.AgentStateStore
end

So the behavior is under the application’s control: use durable state plus the same conversation ID to resume, or use in-memory state when restart recovery isn’t needed.

There are two additional details:

  • Dynamically created sessions are not automatically recreated after a full application restart. The host must summon the session again, normally when the next user message arrives.
  • Spectre restores the confirmation state, but it does not automatically resend the original question. The UI may need to display it again.

This is a good place for next improvements! Thank you.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 15136 120
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New
kip
Please say hi to a new lib, Astro that aims to deliver easy-to-consume astronomy calculations of practical use. For now it only calculat...
New

Other Trending Topics Top

akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews