Microsoft Agent Framework
Microsoft Agent Framework gets a governed chat client pointed at the Omni Gateway LLM proxy, plus policy middleware that stops a run on a governance rejection instead of letting the agent loop retry.
What you get
- A native
agent_framework.openai.OpenAIChatClient, checked against agent-framework 1.19.0. policy_middleware()for terminating a run on aPolicyViolation.- Supported at
connection_kwargs(). The client receives a staticdefault_headerssnapshot, so per-run correlation anddonkey.last_callare not available (see Notes).
Install
pip install "donkey-kit[agent_framework]"Quickstart
Python
from donkey_kit.integrations.agent_framework import chat_client
llm = chat_client("gpt-4o")llm is a real agent_framework.openai.OpenAIChatClient instance.
Three ways to construct
1. Off a shared Donkey instance:
from donkey_kit import Donkey
async with Donkey.from_env() as donkey:
llm = donkey.agent_framework.chat_client("gpt-4o")2. Module-level factory (shortest):
from donkey_kit.integrations.agent_framework import chat_client
llm = chat_client("gpt-4o")3. Governed kwargs, native constructor:
from donkey_kit import Donkey
from agent_framework.openai import OpenAIChatClient
async with Donkey.from_env() as donkey:
llm = OpenAIChatClient(
model="gpt-4o",
**donkey.agent_framework.connection_kwargs(),
)Manual equivalent
from agent_framework.openai import OpenAIChatClient
llm = OpenAIChatClient(
model=..., # `model`, not `model_id`
base_url=..., # from DONKEY_LLM_PROXY_URL, no /v1 suffix
api_key=...,
default_headers=..., # client_id / client_secret header pair
)Policy middleware
donkey.agent_framework.policy_middleware() returns an async
(context, next) middleware that lets a PolicyViolation propagate, so the
host ends the run instead of retrying. It is a plain async wrapper whose
signature has not been confirmed against Agent Framework’s middleware
protocol, so check it in your host before relying on it. Setting Agent
Framework’s explicit “terminate run” signal instead of re-raising is planned
Roadmap.
Notes
- Constructor signature.
OpenAIChatClienttakesmodel,base_url,api_key, anddefault_headers(agent-framework 1.19.0;model_idis not accepted). If the import fails or an upstream release renames a kwarg,chat_client()raises aNotImplementedErrornaming the class path or signature to check, rather than a rawImportErrororTypeError. - No per-run correlation or
donkey.last_call. The client receives a staticdefault_headerssnapshot, which excludes the correlation ID bound later bydonkey.run(id=...), and the SDK’s httpx client is not used. No response reaches the SDK, so gateway identity, routing, and usage fields can’t be observed. When every adapter resolved on aDonkeyis like this one,donkey.last_callreportsstatus == LastCallStatus.UNAVAILABLEandavailable == False, and names the resolved adapters insurface. The conformance suite asserts both as documented exemptions.
See the error taxonomy for the full PolicyViolation hierarchy
that policy_middleware() lets through.