Skip to main content

25 posts tagged with "Microsoft Foundry"

Microsoft Foundry for Building AI Apps, Models, and Agents

View All Tags

How to See Every Message in a Microsoft Agent Framework Agent Run in C#

· 10 min read
Jagdish Kumawat
Founder @ Dewiride

An agent's answer hides how it got there. Did the model call your tool, with which arguments, and what did the tool return? In Microsoft Agent Framework, every agent run keeps the messages it produced, and each message says who wrote it and what it contains. This guide prints them all for a small C# agent that rolls dice.

How to Get the Token Usage and Cost of a Microsoft Agent Framework Agent Run in C#

· 12 min read
Jagdish Kumawat
Founder @ Dewiride

Every call to a model is paid for by the token, and Microsoft Agent Framework tells you how many each run used: AgentResponse.Usage holds the run's input, cached, output and reasoning tokens. This guide reads them in a small C# agent, turns them into a cost in dollars, and gets the same numbers when the answer is streamed.

How to Validate a Function Tool's Arguments in C# with Microsoft Agent Framework

· 13 min read
Jagdish Kumawat
Founder @ Dewiride

The model chooses a tool's arguments, and some are wrong in ways only your code can see: a meeting room that's already taken, an hour outside office hours. Check them in the tool, and when one is wrong, return a message that says what's wrong and what would work, instead of throwing an exception. This guide shows why with a small meeting-room agent and a real model: after an exception, the model can only say that something failed; after a clear message, it offers another room, or books one.

How to Use an Enum Parameter in a Microsoft Agent Framework Function Tool in C#

· 10 min read
Jagdish Kumawat
Founder @ Dewiride

Some tool parameters can only take a few values: a size, a priority, a status. Make such a parameter a C# enum, and Microsoft Agent Framework tells the model exactly which values exist, so it picks one of them instead of making one up. One thing still gets through: a number that isn't one of the values. This guide shows both with a small coffee-ordering agent and a real model, and adds the one-line check that closes the gap.

Fixed: Microsoft Agent Framework Agent Calls a Tool Again After It Succeeded

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

A Microsoft Agent Framework agent that books meeting rooms booked K2, then booked Denali as well, and told the user that no room was free. I first blamed parallel tool calls, and that was wrong. The model called the tool one room at a time, and read the tool's own success message, K2 is booked at 10:00., as K2 is taken. A success message that can't be read as a failure fixed it.

How to See an Agent's Tool Calls in an AG-UI Stream

· 15 min read
Jagdish Kumawat
Founder @ Dewiride

When an agent answers over AG-UI, the text isn't the only thing in the stream: every function tool the agent calls shows up too, as four events, before the answer. This guide builds the smallest agent with one tool, a die roller, and reads each event from a real Microsoft Agent Framework stream, first with one call and then with two calls in the same turn.

How to Add a Function Tool to a Microsoft Agent Framework Agent in C#

· 15 min read
Jagdish Kumawat
Founder @ Dewiride

An AI model can't read a clock, query your database or call your API: it can only ask. A function tool turns a C# method into something a Microsoft Agent Framework agent can ask for, and the agent runs the method for it. This guide adds one tool to a small console app and shows the difference with a real model: without the tool, the agent can't tell the time in Tokyo; with it, it can.