---
title: "Build Tool-Calling Parsers in Rust with AI Agents"
description: "Tool-call parsers in Rust must handle model output that arrives in pieces, with arguments cut short or model-specific markup leaking into the answer. The frontend-crates library provides reusable components behind NVIDIA Dynamo parsers, using a Conformance Corpus of YAML fixtures to test the same behavioral cases across model families. A tutorial demonstrates creating a parser for a new model by defining a GOLDEN test set, implementing the parser against the model’s grammar, and iterating with unit tests. The parser must follow consistent rules for what to emit, what to buffer, and how to handle the end of the stream, preserving valid data without inventing calls. End-to-end testing requires a Dynamo runtime, discovery services, and hardware for the model, with failures turned into regression tests."
---

# Build Tool-Calling Parsers in Rust with AI Agents

[NVIDIA](https://yomu.fyi/company/nvidia-developer-blog) · Keiven Chang · Nov 19, 2026

**Type:** Tutorial

## Summary

Tool-call parsers in Rust must handle model output that arrives in pieces, with arguments cut short or model-specific markup leaking into the answer. The frontend-crates library provides reusable components behind NVIDIA Dynamo parsers, using a Conformance Corpus of YAML fixtures to test the same behavioral cases across model families. A tutorial demonstrates creating a parser for a new model by defining a GOLDEN test set, implementing the parser against the model’s grammar, and iterating with unit tests. The parser must follow consistent rules for what to emit, what to buffer, and how to handle the end of the stream, preserving valid data without inventing calls. End-to-end testing requires a Dynamo runtime, discovery services, and hardware for the model, with failures turned into regression tests.

## Context

Tool-call parsers in Rust must handle malformed, truncated, or interleaved model output without leaking markup or duplicating calls. The frontend-crates library provides reusable components for NVIDIA Dynamo parsers. A Conformance Corpus with YAML fixtures allows testing the same behavioral cases across model families. The tutorial walks through creating a parser for a new model using an AI agent, starting with a prompt, defining a GOLDEN test set, and iterating with unit tests before end-to-end testing on real hardware.

## Approach / What changed

Use an AI agent to create a Rust parser for a new model by defining a GOLDEN test set from the Conformance Corpus, implementing the parser against the model’s grammar, and iterating with unit tests and end-to-end validation.

## Takeaways

- A parser must handle malformed, truncated, and interleaved tool calls without leaking model-specific markup or duplicating calls, using documented recovery rules.
- The Conformance Corpus provides language-neutral YAML fixtures that pair model outputs with expected results, enabling the same behavioral tests across different model families.
- Use finish() for truncation, cancellation, or end of stream; use finish\_at\_eos() only for a backend-confirmed grammar-ending EOS signal.

## FAQ

### How does the parser handle incomplete or malformed tool calls?

The parser consumes token IDs or decoded text and separates reasoning, visible text, and tool calls in order. It uses consistent rules for what to emit, what to buffer, and how to handle the end of the stream, following documented recovery rules for invalid input.

### What is the Conformance Corpus and how is it used?

The Conformance Corpus is a shared set of YAML fixtures that pair model outputs with expected results. It allows Rust parsers and Python references to run the same cases, covering complete, malformed, truncated, multiple, and interleaved calls, plus streaming boundaries.

### When should I use finish() vs finish\_at\_eos()?

Use \`finish()\` for truncation, cancellation, or the end of the transport stream. Use \`finish\_at\_eos()\` only for a backend-confirmed grammar-ending end-of-sequence (EOS) signal.

**Tags:** [AI Agents](https://yomu.fyi/topic/ai-agents), [NVIDIA](https://yomu.fyi/topic/nvidia), [Parsing](https://yomu.fyi/topic/parsing), [Rust](https://yomu.fyi/topic/rust), [Tool Calling](https://yomu.fyi/topic/tool-calling)

- Source: [NVIDIA](https://developer.nvidia.com/blog/build-tool-calling-parsers-in-rust-with-ai-agents)
- Source URL: https://developer.nvidia.com/blog/build-tool-calling-parsers-in-rust-with-ai-agents
- Ingested by Yomu: 2026-11-19T18:00:21.132Z

[Read original post](https://developer.nvidia.com/blog/build-tool-calling-parsers-in-rust-with-ai-agents)
