Conjure.Backend behaviour (Conjure v0.1.1-alpha)
View SourceBehaviour for execution backends.
This behaviour defines the unified interface that all execution backends must implement, enabling pluggable execution strategies.
Available Backends
| Backend | Module | Description |
|---|---|---|
| Local | Conjure.Backend.Local | Bash commands on host |
| Docker | Conjure.Backend.Docker | Bash commands in container |
| Anthropic | Conjure.Backend.Anthropic | Hosted execution via Skills API |
| Native | Conjure.Backend.Native | Elixir modules in BEAM |
Example
# Using a backend directly
session = Conjure.Backend.Local.new_session(skills, [])
{:ok, response, session} = Conjure.Backend.Local.chat(
session,
"Hello",
&api_callback/1,
[]
)Implementing a Custom Backend
defmodule MyApp.Backend.Custom do
@behaviour Conjure.Backend
@impl true
def backend_type, do: :custom
@impl true
def new_session(skills, opts) do
# Create session state
end
@impl true
def chat(session, message, api_callback, opts) do
# Execute chat turn
end
endSee Also
Conjure.Session- Unified session APIConjure.NativeSkill- Behaviour for native skill modules
Summary
Callbacks
Get the backend type identifier.
Execute a chat turn.
Create a new session for this backend.
Types
Callbacks
@callback backend_type() :: atom()
Get the backend type identifier.
Returns an atom identifying this backend (e.g., :local, :docker, :anthropic, :native).
@callback chat(session(), message :: String.t(), api_callback(), opts :: keyword()) :: chat_result()
Execute a chat turn.
Sends a message and returns the response along with updated session state.
Parameters
session- Current session statemessage- User message to sendapi_callback- Function to call the LLM APIopts- Additional options for this turn
Returns
{:ok, response, updated_session}- On success{:error, error}- On failure
Create a new session for this backend.
Parameters
skills- Skills to use (format depends on backend)opts- Backend-specific options
Returns
A new session struct configured for this backend.