maf-doctor maf-testing.instructions.md

maf-doctor maf-testing.instructions.md is an instructions file for GitHub Copilot from joslat/maf-doctor. It costs 1,584 tokens per session, scanned A, original, MIT.

Testing guidance for Microsoft Agent Framework code, including a scripted fake chat client instead of a live language model. It also defines a consistent arrange-act-assert structure for tests.

In plain words
What is it for?
Use it when writing MAF tests for chat behavior, fan-out shapes, parsing, and other logic that should run without live model calls or real network access.
Why use it?
It keeps tests predictable and avoids model costs, network failures, throttling, timing problems, and tests that pass despite changed prompts.

Instructions file for GitHub Copilot

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 instructions/joslat/maf-doctor/maf-testing
Clone the repo
git clone --depth 1 https://github.com/joslat/maf-doctor

Made for: GitHub Copilot.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for maf-doctor maf-testing.instructions.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/joslat/maf-doctor/maf-testing.svg)](https://agentmods.dev/instructions/joslat/maf-doctor/maf-testing)
Your own site
<a href="https://agentmods.dev/instructions/joslat/maf-doctor/maf-testing"><img src="https://agentmods.dev/badge/instructions/joslat/maf-doctor/maf-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,584 This file is loaded in full into every session.
When invoked 1,584 The same file — it is already loaded in full.
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.1 $0.01584 $0.01584
Opus 5 $0.00792 $0.00792
Sonnet 5 $0.00317 $0.00317
Haiku 4.5 $0.00158 $0.00158

Measured 5d ago against content hash b85b502a6dfc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

maf-doctor maf-testing.instructions.md 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 5d 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.

.github/instructions/maf-testing.instructions.md · 138 lines

How it starts

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

MAF Testing — Hermetic Patterns

When you write tests for MAF code in this repo, follow these patterns. They exist because we've been bitten by their absence — every entry has a "why" behind it.

Hard rules

  • No live LLM calls in tests. Ever. Cost is one reason; flakiness, throttling, and "the prompt drifted in production but tests still passed" are the bigger ones.
  • AAA structure with explicit comment markers: // Arrange, // Act, // Assert. Three blocks, separated by a blank line. A test that needs more than 3 blocks is doing too much.
  • One assertion subject per test. Multiple Assert.X(...) calls is fine when they describe one fact (e.g., "this finding has the right ID and the right line").
  • Test name follows Method_Scenario_Outcome. Example: ParseGitDiffOutput_IgnoresBinAndObjPaths_FiltersThem.
  • Hermetic > integration. Prefer in-memory string sources over temp dirs. Prefer temp dirs over real network. Real network needs explicit justification.
  • No Thread.Sleep, no wall-clock dependencies, no GUIDs in assertions. Each is a known source of CI flake.

The ScriptedChatClient pattern (THE canonical mock)

For any test that needs an IChatClient, never instantiate AzureOpenAIClient.AsChatClient(...). Use a scripted mock — same shape as the scaffolder generates:

private sealed class ScriptedChatClient : IChatClient
{
    private readonly string _response;
    public ScriptedChatClient(string response) => _response = response;

    public Task<ChatResponse> GetResponseAsync(
        IEnumerable<ChatMessage> messages,
        ChatOptions? options = null,
        CancellationToken cancellationToken = default)
        => Task.FromResult(new ChatResponse(new ChatMessage(ChatRole.Assistant, _response)));

    public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
        IEnumerable<ChatMessage> messages,
        ChatOptions? options = null,
        [EnumeratorCancellation] CancellationToken cancellationToken = default)
    {
        yield return new ChatResponseUpdate(ChatRole.Assistant, _response);
        await Task.CompletedTask;
    }

    public object? GetService(Type serviceType, object? serviceKey = null) => null;
    public void Dispose() { }
}

Read the full file on GitHub · 138 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. 5d ago First seen · 138 lines · 1,584 tokens per session scan A b85b502a6dfc

Subscribe to this mod's changes

maf-doctor maf-testing.instructions.md is an instructions file published in the GitHub repository joslat/maf-doctor (14 stars, last pushed 18d ago), licensed MIT. It adds 1,584 tokens to every session, about $0.0079 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.