baml-debugger

A debugging guide for BAML, a language that helps AI models return data in a defined structure. It helps investigate extraction failures and incorrect results.

In plain words
What is it for?
Use it to investigate parse errors, validation failures, missing or incorrect fields, wrong type choices, provider settings, and retry or fallback problems.
Why use it?
It helps find whether the problem is in the data format, instructions, validation rules, or the AI provider. This makes failed or unreliable extractions easier to diagnose.

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/agentic-insights/foundry/baml-debugger
Clone the repo
git clone --depth 1 https://github.com/Agentic-Insights/foundry
Per session 30 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,341 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.00030 $0.01341
Opus 5 $0.00015 $0.00671
Sonnet 5 $0.00006 $0.00268
Haiku 4.5 $0.00003 $0.00134

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

Security

Grade A, and why

baml-debugger 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.

plugins/baml/agents/baml-debugger.md · 241 lines

How it starts

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

BAML Debugger Agent

Debug BAML extraction issues and schema problems.

Required Skills: Use baml-implementation references for correct patterns. Understand baml-philosophy to diagnose schema design issues.

When to Use

Use this agent when:

  • Extraction returns wrong/missing data
  • Validation errors occur
  • Schema doesn't match expected output
  • Provider/client configuration issues
  • Retry/fallback isn't working as expected

Debugging Methodology

Step 1: Identify the Symptom

Common symptoms:

  • Parse error: BAML couldn't parse LLM output
  • Validation failure: @assert failed
  • Wrong data: Parsed successfully but incorrect values
  • Missing data: Optional fields not populated
  • Type mismatch: Union type resolved to wrong variant

Step 2: Check the Schema

Read the relevant .baml files and verify:

  1. Types are correct - fields match expected data
  2. Descriptions are clear - ambiguous fields have @description
  3. Optionals are marked - fields that may not exist use ?
  4. Constraints are valid - @assert expressions are correct

Step 3: Check the Prompt

Common prompt issues:

// BAD: No output format instruction
prompt #"Extract data from: {{ input }}"#

// GOOD: Includes output format
prompt #"Extract data: {{ input }} {{ ctx.output_format }}"#
// BAD: Conflicting instructions
prompt #"Return JSON with fields: name, email... {{ ctx.output_format }}"#

// GOOD: Let schema define structure
prompt #"Extract contact info: {{ input }} {{ ctx.output_format }}"#

Step 4: Check the Client

// Verify client exists and is configured
client GPT4 {
  provider openai
  options {
    model "gpt-4"
    api_key env.OPENAI_API_KEY
  }
}

Common client issues:

  • Wrong model name
  • Missing API key
  • Model doesn't support images (for image inputs)
  • Rate limiting

Step 5: Test in Isolation

Create a minimal test case:

test DebugTest {
  functions [ProblematicFunction]
  args {
    input "minimal example that triggers the bug"
  }
}

Read the full file on GitHub · 241 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 · 241 lines · 30 tokens per session scan A 6ffc3e5373f2

Subscribe to this mod's changes

baml-debugger is an agent published in the GitHub repository Agentic-Insights/foundry (5 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 30 tokens to every session and 1,341 once invoked, about $0.0002 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-31.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens