Menu

1 / 2

Structured Output in .NET Agents

DEV Community·Lukas Walter·6 months ago
#i9548772
#dotnet#csharp#ai#enter#exit
Reading 0:00
15s threshold

This is Part 8 of my series on the Microsoft Agent Framework. You can read the original post over on lukaswalter.dev .

LLMs are good at generating text. But text is a weak boundary for application code.

Ask a model for e.g., a specific coffee recipe, and the response might look slightly different every time:

a markdown list

a numbered list

bold section titles

missing fields

additional explanations

a disclaimer at the end

That is fine for a chat interface.

It is not, when your application needs to save the result, display it on a UI, route a workflow, or pass the output into another system.

At that point, you do not want “some text”.

You want data with a known shape.

Raw LLM Text Is Hard to Automate

The problem with unstructured output is not that it looks messy.

The problem is that your application has to guess what the model meant.

For example, if the model returns a coffee recipe as plain text, your code may need to extract:

brew method

coffee dose

water amount

grind size

water…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.