Customize agents and tools#
The Quickstart ran the Branin problem with adda's own defaults: the built-in graph and each shipped agent's own prompt and tools. This page shows how to change who the agents are and which tools each one has. To change the model or backend instead, see Use a different model or backend.
The starting point#
from pathlib import Path
from adda import AgenticRun
study_dir = Path("studies/branin")
study_dir.mkdir(parents=True, exist_ok=True)
(study_dir / "PROBLEM_STATEMENT.md").write_text(
"Minimise the 2D Branin function over its standard domain.\n"
"Report the best design found and the objective value there.\n"
)
AgenticRun(study_dir=study_dir, model="haiku").execute()
No config.yaml here; model is the only thing set, and there's no
backend at all (it defaults to Claude). This runs the built-in graph
(strategizer plus four specialists), every agent on the same backend, every
agent using its own shipped prompt.
Your own agents: a custom graph in Python#
To add one agent to the shipped graph and keep the rest, start from
default_graph(). Define the agent inline with keyword arguments, then add
it and its delegation edge:
from adda import Agent, AgenticRun, default_graph
units = Agent(
description="Checks every reported number for consistent units.",
system_prompt="You check units. Report each mismatch you find.",
tools={"Read"},
)
graph = (
default_graph()
.with_node("units", units)
.with_edge("strategizer", "units") # the strategizer may delegate to it
)
AgenticRun(study_dir=study_dir, graph=graph).execute()
with_edge("a", "b", handoff=True) adds a handoff edge instead: a may pass
the job to b. See Jobs, handoffs, and review.
with_node and with_edge return a new graph and leave the original
unchanged. with_node with an existing name replaces that agent and keeps its
edges. with_edge on an existing pair replaces that edge's preamble.
To replace the agents themselves, build the whole graph. A subclass works as
well as keyword arguments, and you can set backend and model on a node
directly:
from adda import Agent, Edge, Graph, AgenticRun
class Strategist(Agent):
description = "Decides what to try next." # optional: no edge points here
system_prompt = "You are the strategizer. Delegate to the implementer."
tools = frozenset({"Done"}) # this graph has no reviewer: the hub closes
# backend/model unset: this node falls back to the run's own default
class Implementer(Agent):
# Required: the strategizer may delegate here, and reads this to choose.
description = "Writes and runs the evaluation code."
backend = "ollama" # a class attribute override, only for this node
graph = Graph(
nodes={
"strategizer": Strategist(),
"implementer": Implementer(model="qwen2.5:7b"),
},
edges=(Edge("strategizer", "implementer"),), # who may delegate to whom
entry="strategizer", # who gets the initial briefing
)
AgenticRun(study_dir=study_dir, graph=graph).execute()
Run this with no config.yaml (or one that just says backend: claude) and
the strategizer runs on Claude, the run's default, while the implementer
alone runs on Ollama with qwen2.5:7b. If the study's config.yaml also has
a nodes: entry for that agent, the config entry wins over the class.
A bare Agent subclass starts from zero tools (Agent.tools defaults to
frozenset()) and zero epistemic machinery. The shipped agents wire up the
hypothesis ledger, the reproduction gate, and each other's delegation tools
already; a hand-rolled one, like Strategist/Implementer in the example, does not.
No shipped agent sets its own backend. Tests check that each node resolves
its own backend, model and endpoint, but none runs a whole graph that mixes
backends. Running most of a graph on Claude and one node on a local model
works by design, but you may be the first to try it.
Shared prompt blocks: [[include <name>]]#
adda never adds text to an agent's prompt because of its name or class. An agent gets
one of adda's shared blocks only when its own system_prompt names it with an
include marker. Wrap a marker in the feature gate the block belongs to, so the
block disappears when a study turns that feature off:
system_prompt = (
"You build the evaluation code."
"[[if pipeline_deliverable]][[include deliverable_context_implementer]]"
"[[include deliverable_format]][[/if]]"
)
| Block | What it holds |
|---|---|
deliverable_authoring |
How to write pipeline.ipynb with the notebook tools. |
deliverable_context_implementer |
How code fits the notebook's structure. |
deliverable_context_critic |
How to judge a notebook against that structure. |
deliverable_format |
The notebook's required structure and rules. |
reproduction_gate_contract |
The exact checks the reproduction gate runs. |
The shipped strategizer, implementer and critic include the blocks they need.
An unknown name stops the run at startup. On an agent with tools: [Default]
and base_prompt: Default, which runs with no adda text, every marker resolves
to nothing.
Your own function as a tool#
A plain Python function can sit in tools next to the tool names:
from adda import Agent
def Measure(x1: float, x2: float) -> str:
"""Measure the response at (x1, x2) and return it as text."""
return f"y={(x1 - 1) ** 2 + (x2 + 2) ** 2}"
solver = Agent(
system_prompt="Find the minimum. Call Measure to sample a point.",
tools={"Default", "Done", Measure},
)
The function name is the tool name. The docstring is the description that the model reads, and the type hints give the call schema. adda refuses a function that has no docstring, and a lambda, at the moment you build the agent. The tool shows in the viewer's tool list with its docstring, the same as the built-in tools.
Changing one agent's tools: nodes: in config.yaml#
Each agent comes with a set of tools. To change that set for one agent
without writing Python, name the agent in a nodes: block of config.yaml:
nodes:
implementer:
tools: [Default, ReadNote]
The list replaces the agent's own set. It is not added to it, so a tool
you leave out is gone. Agents you do not name keep their usual tools. A node
entry may also set model, backend and base_url for that agent alone, for
example model: haiku. Each is a non-empty string; a base_url is
only valid on a backend that has an endpoint. Three true/false keys set how adda
treats the agent: ledgered_evaluations: true applies the evaluation-ledger
checks to its delegations (on for the implementer and the debugger), and
derivation: true marks its tasks as derivations, which the constraint screen
never pauses (on for the math expert). Every node but the entry works from the
delegation workspace, and every node's preamble gives the run's absolute paths.
handbook_audience, a list of tags, chooses which handbook entries the agent's
menu lists: entries without an audience, plus those that share a tag.
subscribes sets the events that wake the agent (see
Event subscriptions). Any other key is an error. A node name the graph does not have,
or a tools that is not a list of names, stops the run at startup with a
message that names the problem. The study editor in the viewer checks the same
rules before it saves.
Every agent also gets five tools that its class does not declare:
ConsultHandbook, ConsultLiterature, ReportEvals, RecallHistory and the
sandboxed Write. A tools list in config.yaml is the agent's whole set, so
it drops each of these five that it does not name. Name one in the list to keep
it. An agent with no nodes: entry keeps all five. A Default agent keeps the
sandboxed Write. At startup, adda logs the tools a list adds, removes or
withholds (diagnostics row TOOLS_CONFIG_DIFFERS).
Default: the backend's full set of built-in tools#
Default is a tool name that means "every built-in tool this backend has."
- Claude (the default backend): the agent gets the full tool set of the
Claude command-line tool, including web search, web fetch and sub-agents. Other agents
never get these: adda switches them off.
Defaultremoves that restriction for the agent that holds it. One block stays: if the agent also has an adda tool with the same name as a built-in one (for example the sandboxedWrite), the built-in one is switched off, so the sandbox still applies. - Other backends (Ollama, OpenAI-compatible, vLLM):
Defaultmeans that backend's own built-in tools:Bash,BashOutput,KillShell,Read,Write,Edit,GlobandGrep.
Default is never added for you. You can also put it in the tools set of
your own agent class.
A node with Default can step around parts of adda. Its built-in tools do not
go through the delegation tools, the literature rate limiter and cache, the
reproduction gate or the human follow-up channel. adda does not block this.
It tells you.
Notices, not blocks#
adda never stops a run over a tool choice. It records notices in the run's diagnostics feed, the run log and the viewer:
DEFAULT_TOOLS_BYPASS, once per node that holdsDefault. It lists the adda paths that node can bypass.TOOLS_CONFIG_DIFFERS, for every node whose list inconfig.yamlis not the list its class declares. It states which tools were added and which were removed.TOOLS_RESOLVED, once perDefaultnode on the Claude backend, after the Claude command-line tool starts. It lists the built-in tools the node really received and marks any adda has not reviewed.
On another backend, a Default node also gets DEFAULT_TOOLS_EXPANDED: it
names the tools Default turned into there.
The run folder keeps the result: debug/node_tools.json has, for every node,
where its tools came from (class or config.yaml), the class set, the final
set and the difference. It also lists the tools that a switched-off ablation
switch withholds, each with its switch, and the effective set that the node
really has. See Run an ablation.
Event subscriptions: subscribes#
A node can be woken by events in the run's records. Declare them with
subscribes, a map from event name to delivery mode, on the agent class or
in its nodes: entry:
nodes:
critic:
subscribes:
hypothesis_closed: async
monitor_escalation: async
The events:
| Event | Fires when |
|---|---|
hypothesis_closed |
HypothesisUpdate records SUPPORTED, FALSIFIED, or INCONCLUSIVE. |
delegation_done |
A delegation finishes or fails. |
milestone_set |
MilestoneSet marks a milestone DONE or SKIPPED. |
monitor_escalation |
The science monitor's escalation rule fires. |
The modes:
sync: the tool call that caused the event waits for the node's answer, for at most two minutes of silence and one retry. The node's final message is appended to that call's result.delegation_doneandmonitor_escalationhave no waiting call, so they acceptasynconly;syncstops the run at startup with an error that says why.async: the node runs on its own thread. It reaches the node that holds the job only through its own tools, for exampleSendMessage(to="owner", ...). Withpeer_interaction: falseno node hasSendMessage, so anasyncsubscription stops the run at load with an error that names the conflict.
A woken node has its own tools except Done and Handoff, so it never moves
or closes the job, and it starts from its thread when node_threads is on.
At most one wake per node runs at a time; events that arrive meanwhile reach
the next wake together. A node that holds the job is woken for its events when
its tenure ends. A Handoff or Done waits, for at most ten minutes, for
running wakes, and passes on each async message the receiving node has not
received yet: a message the wake already sent it with SendMessage is not
repeated, and a new owner gets the messages sent to the one before. Nothing new
starts after the run closes.
Each event writes a diagnostics row named after it in capitals (for example
HYPOTHESIS_CLOSED), except delegation_done, whose record is the delegation
log row. Each wake is a W### row in delegation_log.jsonl (phase wake)
and its final message is a SUBSCRIBER_MESSAGE row (node, event,
hypotheses, message). A wake that returns no message writes a
WAKE_EMPTY row (node, wake, events), and the same events wake the
node once more. The default graph subscribes the critic to
hypothesis_closed and monitor_escalation, both async: the critic sends
its ruling with SendMessage(to="owner", ...). Set hypothesis_closed: sync
to make the closing update wait for the ruling instead. To turn the
critic's reading of closing verdicts off, give it subscribes: without
hypothesis_closed.
Seeing what you built#
A custom graph is easy to get subtly wrong: a node with the wrong class, an edge to the wrong target, an override that silently didn't take. Render it:
run = AgenticRun(study_dir=study_dir, graph=graph)
run.render_architecture() # writes study_dir/architecture.svg
The SVG shows every node's name, class, description, and the tools it is bound
(read from a real build of the graph, the same list the model receives). It
marks the entry and the nodes that hold Done ("closes the run"). Delegation
edges are solid and handoff edges dashed; an edge back to an earlier row runs
beside the cards. Each card also shows the node's resolved backend/model
(the thing worth checking after the example), exactly as
agent_runtime.py resolves it (agent.model or self._model, agent.backend
or self._backend). For the example graph, that means the diagram should show
the strategizer on the run's default and the implementer on ollama ยท
qwen2.5:7b, on its own card, not a single run-wide banner claiming one
backend for everything. Works before or after execute(); call it any time
you want to check a graph rather than trust it.