Microsoft Agent Framework

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-msaf adds Dynamo to Microsoft Agent Framework. Every agent in a run gets its own capped slice of one budget. An agent used as a tool (Agent.as_tool()) or a hand-off (dyn.handoff(agent)) opens a child slice, which can never exceed what its parent has left. A model call that would go over its slice is refused before the chat client is called.

The plugin is not published. It installs from a clone of the repository.

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 chat client: no provider key, no model called. You need 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-msaf
PIP_ONLY_BINARY=":all:" .venv-msaf/bin/pip install --quiet --require-hashes -r packages/plugin-msaf/locks/test.txt
.venv-msaf/bin/pip install --quiet --no-deps ./packages/sdk-python ./packages/plugin-msaf
for _ in $(seq 150); do curl -fsS "$DYNAMO_CORE_URL/healthz" > /dev/null 2>&1 && break; sleep 0.2; done
.venv-msaf/bin/python packages/plugin-msaf/examples/containment/run.py
kill "$CORE_PID"; trap - EXIT

Delete .venv-msaf when you are done.

Wrap an agent run in a budget

This is packages/plugin-msaf/examples/app/with_dynamo.py: an orchestrator that calls specialists exposed with as_tool(), with Dynamo added. make test-plugin-msaf runs it against a local core (tests/test_examples.py).

# SPDX-License-Identifier: Apache-2.0
"""A small multi-agent app on Microsoft Agent Framework — with Dynamo.

Runs offline: the scripted mock client stands in for a real one.
"""

import asyncio

from agent_framework import Agent

from dynamoprotocol_msaf import AgentConfig, DynamoMSAF, usd
from dynamoprotocol.testing import mock_prices
from dynamoprotocol_msaf.testing import ScriptedClient, Text, ToolCall, Upstream

upstream = Upstream()
SCRIPT = {"orchestrator": [ToolCall("researcher", {"task": "find sources"}), Text("three sources found")], "researcher": [Text("three sources")], "writer": [Text("draft written")]}
OPTIONS = {"model": "mock/scripted-1", "max_tokens": 256}


def client(name):
    c = ScriptedClient("mock/scripted-1", upstream, agent=name)
    c.queue.extend(SCRIPT[name])
    return c


def agent(name, **kwargs):
    return Agent(client=client(name), name=name, default_options=OPTIONS, middleware=dyn.middleware(name), **kwargs)


async def main():
    global dyn
    dyn = await DynamoMSAF.connect(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")})
    specialists = [agent("researcher").as_tool(), agent("writer").as_tool()]
    orchestrator = agent("orchestrator", tools=specialists)
    result = await dyn.run(orchestrator, "Write a brief on grid-scale storage")
    print(result.text.strip())
    await dyn.close()


asyncio.run(main())

its agent tools. An agent's name is its Dynamo key.

max_completion_tokens or max_output_tokens in its options, for example in default_options), or pass default_completion_tokens to connect; a call with neither is refused (unbounded). The worst case of each call is reserved before it is made.

DYNAMO_CORE_URL and DYNAMO_OWNER_TOKEN point it at your core. With a real model, pass your price table instead of mock_prices(); an unknown model is refused.

What a refusal looks like

A refusal raises DynamoCapExceeded, DynamoMandateRefused, DynamoRevoked, DynamoUnpricedModel, DynamoFrozen, DynamoStopped, DynamoApprovalPending, DynamoApprovalDenied or DynamoAmendmentRefused, all subclasses of DynamoMSAFError (an Agent Framework MiddlewareFailure). Agent Framework never hands it to the model as a tool error: it aborts the run and propagates out of Agent.run.

Funding modes

always a Control Mode budget: every check runs and no money moves. The quickstart and every test of this plugin use one.

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.

operator allows it, and real-money settlement is not released.

Known limits

Read packages/plugin-msaf/KNOWN-LIMITS.md in the repository before you rely on the plugin.