← Back to Tutorials

10. Microsoft Agent Framework

MAF in Foundry

The Microsoft Agent Framework (MAF) is integrated with Foundry to provide a rich SDK for building agents with tools, memory, and structured outputs.

Basic Chat Agent

import { Agent, AgentClient } from "@microsoft/agents";

const agent = new Agent({
  name: "HelpDeskAgent",
  instructions: "You are an IT help desk assistant.",
  model: "gpt-4o",
});

const client = new AgentClient(agent);
const response = await client.sendMessage("How do I reset my password?");
console.log(response.text);

MCP Tool Agent

import { Tool } from "@microsoft/agents";

const ticketTool = new Tool({
  name: "create_ticket",
  description: "Create an IT support ticket",
  parameters: {
    title: { type: "string" },
    priority: { type: "string", enum: ["low", "medium", "high"] }
  },
  handler: async (args) => {
    return await createTicketInServiceNow(args);
  }
});

agent.addTool(ticketTool);

Multi-Tool Agent

// Combine knowledge base search + ticket creation
agent.addTools([
  knowledgeBaseTool,
  ticketTool,
  calendarTool,
  emailTool
]);

DevUI Visualization

MAF's DevUI provides a visual debugger for agent conversations, tool calls, and memory state. Use it during development to inspect agent behavior.

Structured Outputs

const agent = new Agent({
  name: "DataExtractor",
  instructions: "Extract structured data from text.",
  outputSchema: {
    type: "object",
    properties: {
      name: { type: "string" },
      date: { type: "string" },
      amount: { type: "number" }
    },
    required: ["name", "date", "amount"]
  }
});

Sequential & Parallel Workflows

MAF supports orchestrating multiple agents in sequence (pipeline) or in parallel (fan-out) using the Orchestrator.

✏️ Exercise: Build a multi-tool MAF agent that uses three tools: a knowledge base search tool, a ticket creation tool, and an email notification tool. Test with a scenario where a user asks about a known issue and requests a ticket.