Conjure.Backend.Native (Conjure v0.1.1-alpha)
View SourceBackend for native Elixir module execution.
Executes skills implemented as Elixir modules directly in the BEAM, providing type-safe, in-process execution with full access to the application's runtime context.
Usage
defmodule MyApp.Skills.Database do
@behaviour Conjure.NativeSkill
def __skill_info__ do
%{
name: "database",
description: "Query the database",
allowed_tools: [:execute, :read]
}
end
def execute(query, _context), do: {:ok, run_query(query)}
def read(table, _context, _opts), do: {:ok, get_schema(table)}
end
session = Conjure.Backend.Native.new_session([MyApp.Skills.Database], [])
{:ok, response, session} = Conjure.Backend.Native.chat(
session,
"What tables do we have?",
&api_callback/1,
[]
)How It Works
- Native skill modules implement
Conjure.NativeSkillbehaviour - This backend generates Claude tool definitions from skill info
- When Claude returns tool_use blocks, this backend:
- Maps tool names back to skill modules
- Invokes the appropriate callback (execute/read/write/modify)
- Returns results to Claude
Advantages Over Local Backend
- No subprocess/shell overhead
- Type-safe with compile-time checks
- Direct access to application state (Ecto repos, caches, GenServers)
- Better error handling with pattern matching
Options
:working_directory- Working directory for file operations:timeout- Execution timeout in milliseconds (default: 30_000):max_iterations- Maximum tool-use iterations (default: 25)
See Also
Conjure.NativeSkill- Behaviour for skill modulesConjure.Backend.Local- Shell-based execution
Summary
Functions
Build a tool name to module mapping for dispatching.
Get all tool definitions for a list of native skill modules.
Functions
Build a tool name to module mapping for dispatching.
Returns a map from tool name to {module, callback_type}.
Get all tool definitions for a list of native skill modules.
Returns a list of tool definitions suitable for passing to the Claude API.