safety

A set of security practices for building AI agents. It explains where user input, conversation history, outside context, AI services, and function tools cross trust boundaries.

In plain words
What is it for?
Use it to review input validation, data handling, AI-service access, chat-history storage, and the configuration of tools available to an agent.
Why use it?
It helps developers identify places where sensitive data could leak, untrusted instructions could influence the agent, or tools could be used unsafely.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/managedcode/dotnet-skills/safety
Clone the repo
git clone --depth 1 https://github.com/managedcode/dotnet-skills
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,596 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00014 $0.01596
Opus 5 $0.00007 $0.00798
Sonnet 5 $0.00003 $0.00319
Haiku 4.5 $0.00001 $0.00160

Measured yesterday against content hash 2a0e3dd8f937, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

safety scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

catalog/Frameworks/Microsoft-Agent-Framework/skills/microsoft-agent-framework/references/official-docs/concepts/agents/safety.md · 120 lines

How it starts

The opening of the file, as written. The whole thing — 120 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Safety

Building secure AI agents is a shared responsibility between Agent Framework and application developers. Agent Framework provides the building blocks — abstractions, providers, and orchestration — but developers are responsible for validating inputs, securing data flows, and configuring tools appropriately for their scenario.

This article outlines best practices for building safe and secure agents with Agent Framework.

[!TIP] For deterministic, label-based defense against prompt injection and data exfiltration, see Agent Security with FIDES. FIDES complements the heuristic best-practices on this page with information-flow control middleware that enforces policies before sensitive tools run.

Understand trust boundaries

Data flows through several components when an agent runs: user input, chat history providers, context providers, the LLM service, and function tools. Each boundary where data enters or exits your application represents a potential attack surface.

Key trust boundaries to consider:

  • AI service — Receives chat messages (which may include PII and system instructions) and returns LLM-generated output.
  • Chat history storage — Providers may load and persist conversation messages via external storage.
  • Context services — Context providers may retrieve or store data from external services (memories, user profiles, RAG results).
  • Tool-accessed services — Function tools execute developer-supplied code that may call external APIs or databases.

All external service communication is handled by developer-chosen client SDKs. Agent Framework does not manage authentication, encryption, or connection details for these services.

Best practices

Validate function inputs

The AI can call any function you provide as a tool and choose the arguments. Treat LLM-provided arguments as untrusted input, similar to user input in a web API.

  • Use allow-listing — Validate inputs against known-good values rather than trying to filter known-bad patterns. For example, check that a file path is within an allowed directory rather than checking for .. traversal sequences.
  • Enforce type and range constraints — Verify that arguments are of the expected type and within acceptable ranges (numeric bounds, string length limits, date ranges).
  • Limit string lengths — Enforce maximum lengths on string arguments to prevent resource exhaustion or injection attacks.
  • Prevent path traversal — When functions accept file paths, resolve them to absolute paths and verify they fall within allowed directories.
  • Use parameterized queries — If arguments are used in SQL queries, shell commands, or other interpreted contexts, use parameterized queries or escaping — never string concatenation.

Read the full file on GitHub · 120 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 120 lines · 14 tokens per session scan A 2a0e3dd8f937

Subscribe to this mod's changes

safety is an agent published in the GitHub repository managedcode/dotnet-skills (477 stars, last pushed 2d ago), licensed MIT. It adds 14 tokens to every session and 1,596 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.