Jidoka: Ash Resources
ash_resource expands an Ash resource’s AshJido actions into agent-callable
tools and injects the resource domain into runtime context.
Setup
Mix.install(
[
{:jidoka, git: "https://github.com/mikehostetler/jidoka.git", ref: "924a486f3c1b7e7a943cb3d5ceee0de65f158467"},
{:kino, "~> 0.19.0"}
],
config: [
jidoka: [
model_aliases: %{fast: "anthropic:claude-haiku-4-5"}
]
]
)
Jidoka.Kino.setup()
Attach An Ash Resource
Jidoka ships a small example Ash resource used by the kitchen-sink demo.
defmodule LivebookDemo.AshResources.Agent do
use Jidoka.Agent
agent do
id :livebook_ash_resource_agent
end
defaults do
model :fast
instructions "You can use Ash resource tools."
end
capabilities do
ash_resource Jidoka.Examples.KitchenSink.Ash.User
end
end
%{
ash_resources: LivebookDemo.AshResources.Agent.ash_resources(),
ash_domain: LivebookDemo.AshResources.Agent.ash_domain(),
requires_actor?: LivebookDemo.AshResources.Agent.requires_actor?(),
tool_names: LivebookDemo.AshResources.Agent.tool_names()
}
Actor Context Is Required
Ash-backed agents require an actor in runtime context before the provider is
called.
{:ok, pid} =
Jidoka.Kino.start_or_reuse("livebook-ash-resource-agent", fn ->
LivebookDemo.AshResources.Agent.start_link(id: "livebook-ash-resource-agent")
end)
{:error, error} = LivebookDemo.AshResources.Agent.chat(pid, "List users.")
Jidoka.format_error(error)
When actor is present, Jidoka adds the Ash domain to the internal tool context.
{:ok, opts} =
Jidoka.Agent.prepare_chat_opts(
[context: %{actor: %{id: "user-1", name: "Livebook User"}}],
%{
domain: LivebookDemo.AshResources.Agent.ash_domain(),
require_actor?: LivebookDemo.AshResources.Agent.requires_actor?()
}
)
Keyword.fetch!(opts, :tool_context)
Optional Provider Turn
Jidoka.Kino.chat("Ash resource chat", fn ->
LivebookDemo.AshResources.Agent.chat(
pid,
"What Ash resource tools are available?",
context: %{actor: %{id: "user-1", name: "Livebook User"}}
)
end)