CrewAI
Not in the preview yet. This feature is built in the repository but is off in the v2.2.6 preview (test mode). Do not treat this page as available on a preview core. See ../preview.md and the release notes.
dynamoprotocol-crewai adds Dynamo to CrewAI. Every agent in a crew gets its own capped slice of one budget. Delegating work to a coworker, or asking a coworker a question, opens a child slice for the coworker, which can never exceed what the delegating agent has left. A model call that would go over its slice is refused before the model is called.
The plugin is not published. It installs from a clone of the repository. CrewAI does not install from binary wheels on Intel macOS, so the plugin is tested on Linux (in Docker on Intel macOS).
Install and try it
These are the commands from the plugin README. They boot a local core in Control Mode, build a venv from the hash-checked locks/test.txt and run the offline containment demo on a scripted mock LLM with CrewAI telemetry off. You need Linux on x86_64, Node 22.12 or later, pnpm 9, curl, openssl and Python 3.11 (set PYTHON=python3.11 if python3 is another version). Set DYNAMO_REPO to your clone.
cd "$DYNAMO_REPO"
pwd
pnpm install --frozen-lockfile
pnpm --filter @dynamo/core-host... -r build
export DYNAMO_OWNER_TOKEN="dp-local-owner-$(openssl rand -hex 16)"
export DYNAMO_CORE_URL="http://127.0.0.1:${DYNAMO_CORE_PORT:-8790}"
[ -s .dynamo-local.key ] || (umask 077 && openssl rand -hex 32 > .dynamo-local.key)
export CORE_KEY_ENCRYPTION_KEY="$(cat .dynamo-local.key)"
OWNER_API_TOKEN="$DYNAMO_OWNER_TOKEN" PLUGIN_WIRE_TOKEN="dp-local-wire-$(openssl rand -hex 16)" \
OWNER_API_PORT="${DYNAMO_CORE_PORT:-8790}" CORE_DB="$PWD/.dynamo-local/core" CORE_LOG=off \
CORE_RATE_LIMIT_RPS=200 CORE_RATE_LIMIT_BURST=400 \
node deploy/image/entry.mjs > .dynamo-local.log 2>&1 &
CORE_PID=$!
trap 'kill "$CORE_PID"' EXIT
"${PYTHON:-python3}" -m venv .venv-crewai
PIP_ONLY_BINARY=":all:" .venv-crewai/bin/pip install --quiet --require-hashes -r packages/plugin-crewai/locks/test.txt
.venv-crewai/bin/pip install --quiet --no-deps ./packages/sdk-python ./packages/plugin-crewai
for _ in $(seq 150); do curl -fsS "$DYNAMO_CORE_URL/healthz" > /dev/null 2>&1 && break; sleep 0.2; done
kill -0 "$CORE_PID" 2>/dev/null && curl -fsS "$DYNAMO_CORE_URL/healthz" > /dev/null || tail -n 20 .dynamo-local.log
.venv-crewai/bin/python packages/plugin-crewai/examples/containment/run.py
kill "$CORE_PID"; trap - EXIT
The last line stops the core. Delete .venv-crewai when you are done.
Wrap an agent run in a budget
This is packages/plugin-crewai/examples/app/with_dynamo.py: a small crew whose orchestrator delegates to a researcher, with Dynamo added. make test-plugin-crewai runs it against a local core (tests/test_examples.py).
# SPDX-License-Identifier: Apache-2.0
"""A small CrewAI crew with delegation — with Dynamo.
Runs offline: the scripted mock LLM stands in for a real one.
"""
from crewai import Agent, Crew, Process, Task
from dynamoprotocol_crewai import AgentConfig, DynamoCrew, usd
from dynamoprotocol.testing import mock_prices
from dynamoprotocol_crewai.testing import ScriptedLLM, Text, ToolCall, Upstream
upstream = Upstream()
ASK = {"task": "find sources", "context": "a brief on grid-scale storage", "coworker": "researcher"}
SCRIPT = {"orchestrator": [ToolCall("delegate_work_to_coworker", ASK), Text("brief: three sources found")], "researcher": [Text("three sources found")], "writer": [Text("draft written")]}
def agent(role):
llm = ScriptedLLM(model="mock/scripted-1", upstream=upstream, label=role, max_tokens=256)
llm.queue.extend(SCRIPT[role])
return Agent(role=role, goal=f"act as the {role}", backstory=f"the {role}", llm=llm, allow_delegation=role == "orchestrator", verbose=False)
dyn = DynamoCrew.start(
prices=mock_prices(), cap=usd("5"), mandate={"categories": ["research", "writing", "review"], "maxDepth": 3},
agents={"orchestrator": AgentConfig(usd("5"), "review"), "researcher": AgentConfig(usd("1"), "research"), "writer": AgentConfig(usd("1"), "writing")},
)
agents = [agent(role) for role in SCRIPT]
task = Task(description="Write a brief on grid-scale storage", expected_output="a brief", agent=agents[0])
crew = Crew(agents=agents, tasks=[task], process=Process.sequential, verbose=False)
print(dyn.kickoff(crew).raw)
dyn.close()
DynamoCrew.start(...)(orawait DynamoCrew.connect(...)in async code)
opens a budget with your cap and mandate. It reads DYNAMO_CORE_URL and DYNAMO_OWNER_TOKEN when you do not pass core_url and token.
dyn.kickoff(crew)replacescrew.kickoff(); from async code use
await dyn.akickoff(crew).
- Agent keys are the agents'
rolestrings.
With a real model, pass your price table instead of mock_prices() (for example prices="quickstart/dynamo-guard/prices.json") or set DYNAMO_PRICE_TABLE. A model with no row is refused.
What a refusal looks like
A refusal is a CrewAI HookAborted exception (CrewAI propagates it out of kickoff without retrying) that is also one of the layer's DynamoAgentError classes, so you can catch either: DynamoCapExceeded, DynamoMandateRefused, DynamoRevoked, DynamoUnpricedModel, DynamoFrozen, DynamoStopped, DynamoApprovalPending, DynamoApprovalDenied and DynamoAmendmentRefused. Each carries stream_id, reason (the Dynamo reason code) and headroom.
A refused delegation blocks the tool, and the refusal ends the run at the delegating agent's next model call, before that call reaches the model.
Funding modes
- Control Mode (Live). A budget the plugin opens itself (
cap=) is
always a Control Mode budget: every check runs and no money moves. The quickstart and every test of this plugin use one.
- A funded budget. You can pass an existing stablecoin or credit card
budget by id (budget_id=). The plugin does not refuse it, but no test runs the plugin on one. In those modes the core requires signed hops by default, and a child slice opened without its delegator's signature is refused hop_unsigned. Pass hops= (a LayerHops from dynamoprotocol.agents: the delegator's key and each payee's own signed offer) so the plugin signs every hop it opens.
- Real money (Release-gated). A core runs a money mode only when its
operator allows it, and real-money settlement is not released.
Known limits
Read packages/plugin-crewai/KNOWN-LIMITS.md in the repository before you rely on the plugin. It covers the chromadb advisories that CrewAI's install brings in.