Agent framework defenses against prompt injection in C# using Claude
A walkthrough shows how a C# agent can be shielded from prompt injection, where instructions hidden in tool-returned data trick the model into acting against the user's request. The example uses a recipe assistant whose imported recipe note tries to get the shopping list shared with an outside address. The author measures how often the model follows the planted instruction across repeated runs, using Microsoft Agent Framework 1.24.0 on .NET 10 with Claude Haiku 5.5. Three code-level checks are added around the agent, in the tool, in function middleware, and in agent middleware on output. The article also covers least-privilege design and approval steps as alternatives, noting what each defense fails to stop.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in