Condukt is an Elixir library for building reliable AI agents.
Use Condukt when agents should live inside your OTP system. It provides the agent runtime, tool system, sandboxing model, project instructions, provider support, structured output, redaction, secrets, streaming, and telemetry.
Add Condukt to your Elixir application:
def deps do
[
{:condukt, "~> 1.5"}
]
endThis example shows the common shape: define an agent, grant tools, delegate to a sub-agent, expose a typed operation, run one-shot tasks, and stream a persistent session.
defmodule MyApp.ProjectAgent do
use Condukt
@impl true
def model, do: "anthropic:claude-sonnet-4-20250514"
@impl true
def system_prompt do
"You help maintain this repository. Prefer concrete findings and patches."
end
@impl true
def tools do
Condukt.Tools.coding_tools() ++
[{Condukt.Tools.Command, command: "git"}]
end
@impl true
def subagents do
[
reviewer: [
system_prompt: "Review changes and return concise blockers first.",
tools: Condukt.Tools.read_only_tools(),
output: %{
type: "object",
properties: %{
summary: %{type: "string"},
blockers: %{type: "array", items: %{type: "string"}}
},
required: ["summary", "blockers"]
}
]
]
end
operation :release_notes,
input: %{
type: "object",
properties: %{version: %{type: "string"}},
required: ["version"]
},
output: %{
type: "object",
properties: %{
title: %{type: "string"},
highlights: %{type: "array", items: %{type: "string"}}
},
required: ["title", "highlights"]
},
instructions: "Draft release notes from the git history and project files."
end
api_key = System.fetch_env!("ANTHROPIC_API_KEY")
{:ok, %{summary: summary}} =
Condukt.run(MyApp.ProjectAgent, "Summarize README.md in one paragraph.",
api_key: api_key,
cwd: ".",
input: %{path: "README.md"},
input_schema: %{
type: "object",
properties: %{path: %{type: "string"}},
required: ["path"]
},
output: %{
type: "object",
properties: %{summary: %{type: "string"}},
required: ["summary"]
}
)
{:ok, notes} =
MyApp.ProjectAgent.release_notes(%{version: "1.3.0"},
api_key: api_key
)
{:ok, agent} =
MyApp.ProjectAgent.start_link(
api_key: api_key,
cwd: ".",
redactor: Condukt.Redactors.Regex,
compactor: {Condukt.Compactor.Sliding, keep: 40}
)
agent
|> Condukt.stream("Review the last commit and delegate if useful.")
|> Stream.each(fn
{:text, chunk} -> IO.write(chunk)
{:tool_call, name, _id, _args} -> IO.puts("\nUsing #{name}")
:done -> IO.puts("\nDone")
_event -> :ok
end)
|> Stream.run()Start here:
Build agents:
- Agents
- One-Shot Runs
- Tools
- Sub-agents
- Operations
- Streaming and Events
- Sessions and Persistence
- Compaction
Run production integrations:
MIT License. See LICENSE for details.
