Skip to Content
FrameworksMS Agent Framework

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 a PolicyViolation.
  • Supported at connection_kwargs(). The client receives a static default_headers snapshot, so per-run correlation and donkey.last_call are not available (see Notes).

Install

pip install "donkey-kit[agent_framework]"

Quickstart

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. OpenAIChatClient takes model, base_url, api_key, and default_headers (agent-framework 1.19.0; model_id is not accepted). If the import fails or an upstream release renames a kwarg, chat_client() raises a NotImplementedError naming the class path or signature to check, rather than a raw ImportError or TypeError.
  • No per-run correlation or donkey.last_call. The client receives a static default_headers snapshot, which excludes the correlation ID bound later by donkey.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 a Donkey is like this one, donkey.last_call reports status == LastCallStatus.UNAVAILABLE and available == False, and names the resolved adapters in surface. The conformance suite asserts both as documented exemptions.

See the error taxonomy for the full PolicyViolation hierarchy that policy_middleware() lets through.

Last updated on