The same PDF invoice agent, rebuilt with Microsoft Agent Framework instead of hand-written HttpClient code: about 320 lines drop to 136. The author logs the outgoing requests and shows the three defaults that would bite you if you never looked.
Key points
- Microsoft.Agents.AI.OpenAI already pulls in the OpenAI .NET SDK and Microsoft.Extensions.AI, so you don't add them.
- Azure.AI.OpenAI 2.9.0-beta.1 compiles next to Agent Framework 1.26.0, then throws MissingMethodException inside GetResponsesClient() at startup.
- The workaround is the v1 endpoint: ResponsesClient points at https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1 with no Azure-specific client.
- AIFunctionFactory.Create derives the tool schema from the method signature and [Description] attributes; without a name it ships a generated one like _Main_g_CheckSupplier_0_0.
- Strict mode is off by default: send "strict": true through additional properties on both AIFunctionFactoryOptions and ChatOptions.
- RunAsync<InvoiceReview>() builds the schema from the record, runs the tool loop and deserializes the answer; reasoning effort goes through RawRepresentationFactory.
Real-world use
- An accounts payable workflow that reads supplier invoices as PDFs and decides whether approval is needed
- An agent flow with a tool call that checks the invoice supplier against an ERP vendor master
- A production app where a hand-written tool loop gives way once a second tool, streaming or human approval is added
This summary was generated by the agent from the original post on DEV Community: #csharp. The full text and all rights belong to its author and publisher. Go to original