declarative

A way to define AI agents in YAML or JSON configuration files instead of writing their setup entirely in code. YAML and JSON are text formats commonly used for structured settings.

In plain words
What is it for?
Use it to create agents from configuration files in a C# project, including projects that use Azure OpenAI.
Why use it?
It makes agent settings easier to read, change, and share across a team.

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/declarative
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,612 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.01612
Opus 5 $0.00007 $0.00806
Sonnet 5 $0.00003 $0.00322
Haiku 4.5 $0.00001 $0.00161

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

Security

Grade A, and why

declarative 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 2d ago.

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/agents/declarative.md · 218 lines

How it starts

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

Declarative Agents

Declarative agents allow you to define agent configuration using YAML or JSON files instead of writing programmatic code. This approach makes agents easier to define, modify, and share across teams.

:::zone pivot="programming-language-csharp"

Prerequisites

To use declarative agents in C#, add the Microsoft.Agents.AI.Declarative NuGet package to your project, alongside the chat client package for your provider (for example, Azure.AI.OpenAI):

dotnet add package Microsoft.Agents.AI.Declarative --prerelease
dotnet add package Azure.AI.OpenAI
dotnet add package Azure.Identity

The Microsoft.Agents.AI.Declarative package provides the ChatClientPromptAgentFactory type and the CreateFromYamlAsync extension method on PromptAgentFactory used in the examples below.

Define an agent inline with YAML

You can define the full YAML specification as a string directly in your code, then create an AIAgent from it with ChatClientPromptAgentFactory:

using Azure.AI.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;

var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
    ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini";

// Create the chat client
IChatClient chatClient = new AzureOpenAIClient(
    new Uri(endpoint),
    new DefaultAzureCredential())
        .GetChatClient(deploymentName)
        .AsIChatClient();

// Define the agent using a YAML definition.
var yamlDefinition =
    """
    kind: Prompt
    name: Assistant
    description: Helpful assistant
    instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format.
    model:
        options:
            temperature: 0.9
            topP: 0.95
    outputSchema:
        properties:
            language:
                type: string
                required: true
                description: The language of the answer.
            answer:
                type: string
                required: true
                description: The answer text.
    """;

// Create the agent from the YAML definition.
var agentFactory = new ChatClientPromptAgentFactory(chatClient);
var agent = await agentFactory.CreateFromYamlAsync(yamlDefinition);

// Invoke the agent and output the text result.
Console.WriteLine(await agent!.RunAsync("Tell me a joke about a pirate in English."));

// Invoke the agent with streaming support.
await foreach (var update in agent!.RunStreamingAsync("Tell me a joke about a pirate in French."))
{
    Console.WriteLine(update);
}

Read the full file on GitHub · 218 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. 2d ago First seen · 218 lines · 14 tokens per session scan A c867a59caf2c

Subscribe to this mod's changes

declarative 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,612 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.