Define a named agent in a script, function or IEx session. The block returns
a regular Nous.Agent.
import Nous.DSL
agent "Trip calculator" do
model "openai:gpt-4o-mini"
instructions "Round distances to one decimal place."
prompt "How many miles is a 42.2 km marathon?"
tool miles(km: :number), fn km -> km * 0.621371 end
fallback ["ollama:qwen3"]
endDeclare one primary model. The optional fallback list sets the order in
which the runner tries other models. prompt sets the default user message
for Nous.run/1. An explicit input overrides it for one run.
Use tool MyApp.Search for a behaviour module, a function capture or a
previously built tool. Repeated tool and plugin declarations keep their
order. Lists can be written as tools [Search, Fetch] or plugins [Memory].
Select remote tools with mcp docs: [:search, :fetch].
Additional fields include model_settings, max_iterations, retries
and parallel_tool_calls. Pass additional Nous.new/2 options after the
name, e.g. agent "Local assistant", base_url: url do ... end.
Load a file definition with Nous.load_agent/2.
Summary
Functions
Build an agent from the declarations in the block.
Build a reusable tool from a positional function. Parameters are required and passed to the function in declaration order. The signature sets the public tool name.
Build an inline tool with a description. Each named parameter is required
and bound inside the body. Types are :string, :integer, :number,
:boolean, :array and :object. Use Nous.Tool.Schema for optional
parameters, execution context and approval metadata.
Functions
Build an agent from the declarations in the block.
Build a reusable tool from a positional function. Parameters are required and passed to the function in declaration order. The signature sets the public tool name.
tool miles(km: :number), fn km -> km * 0.621371 end
Build an inline tool with a description. Each named parameter is required
and bound inside the body. Types are :string, :integer, :number,
:boolean, :array and :object. Use Nous.Tool.Schema for optional
parameters, execution context and approval metadata.
tool greet(name: :string), "Greet someone" do
"Hello, " <> name
end