MICROSOFT AGENT FRAMEWORK · 0.16.0-rc.1
Demo120 — Tool Hallucination
Refuse an invented value when the invoice is absent.
Objectives
- Reject invented tool results and inspect actual business effects.
Prepare the demo
Start at the root of the complete solution already built in Release. Course prerequisites: Demo060. This program uses live chat from the selected profile; no embeddings are required except for Demo020 --embed. Check connectivity and required capabilities before attributing failure to the scenario.
| Project | Role |
|---|---|
| demos/Demo120_ToolHallucination/Demo120.App.csproj | App |
Launch from the root
dotnet run --project demos/Demo120_ToolHallucination/Demo120.App.csproj -c Release --no-buildModes and procedure
The program automatically asks InvoiceReader for INV-404 through find_invoice. Chat uses a live provider; the invoice remains an explicitly simulated local fixture. No menu or interactive input.
var agent = chat.AsAIAgent(name: "InvoiceReader", instructions:
"Call find_invoice for INV-404. Never invent missing data. Answer in English.",
tools: [AIFunctionFactory.Create(FindInvoice, "find_invoice")]);
Console.WriteLine("Assistant declaration: " + (await agent.RunAsync("Read invoice INV-404.", cancellationToken: stop.Token)).Text);
Console.WriteLine(observed.Count == 0 ? "No invocation observed; no verified answer."
: "Host answer from observed tool result: " + observed.Last().ToAnswer());
Results and useful failures
An observed INV-404 call returns NotFound with null Value. ToAnswer() yields No matching data exists in the demo fixture. Compare this host answer with Assistant declaration. Without tool invocation, the console reports No invocation observed; no verified answer. Distinguish missing data, refusal and error.
These observations are expected from inspecting the indicated code revision. No new model call was made to write this page; exact generated wording is not a reference output.
Scope and limits
The “Never invent missing data” prompt guides the model; ToAnswer enforces the factual host answer. LookupResult tests also cover Refused and Error; the current program has no switch for simulating each status.
