Microsoft Agent Framework
Already building MAF agents with AzureOpenAIChatClient? Skip to the next lesson.
Microsoft has had several agent libraries. Semantic Kernel and AutoGen were solving the same problem from two directions. Microsoft Agent Framework, usually shortened to MAF, is where those lines meet. AutoGen is now in maintenance mode, so do not start a new project there.
What actually changes
The difference you will feel immediately is the tool description.
In Module 3 you hand-wrote the JSON schema yourself. In MAF you write an ordinary function and hand over the function:
def check_licence_seats(product: str) -> str:
"How many seats are left for a product."
...
agent = client.create_agent(
name="helpdesk",
instructions="...",
tools=[check_licence_seats],
)
MAF reads the function's name, its parameters, its type hints and its description, and writes that JSON for you.
That is a real convenience, and it is worth knowing it is only a convenience. You wrote that JSON by hand once, so you can picture exactly what the framework generated and debug it when the model calls a tool strangely.
Agent or workflow
Start with a single agent. Reach for a workflow, which is MAF's word for several agents co-ordinating, only when the roles genuinely differ. That is Module 16's argument, and most designs that reach for a workflow wanted one agent with better tools.
What to write
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import DefaultAzureCredential
- Build the client with an endpoint, a deployment name and a credential
- Write
check_licence_seats(product)as an ordinary typed function create_agent(...)with that function intoolsagent.run(QUESTION)and print the result
The point
The framework's main gift is writing the tool description you already know how to write yourself.
Break it on purpose
Remove the type hint from product. The description still builds and the
model has less to go on. Then take the function out of tools and watch the
agent lose the ability to answer at all.
Check yourself
Answer out loud first. Reading the answer without trying is where the learning leaks out.
1. When is workflow worth it over a single agent?
2. Where did the tool schema you hand-wrote in Module 3 go?
3. What does AzureOpenAIChatClient replace in your hand-rolled loop?
4. Did the agent loop idea change, or only the hosting library?