Fine-Tuning an Open Model on Agent Traces: LangChain's Results

Fine-Tuning an Open Model on Agent Traces: LangChain's Results

Agentic AI

LangChain’s fine-tuned GLM 5.3 Flash scored 0.735 on its docs-question benchmark, against 0.748 for GPT-6.1 Sol, while costing 83% less, according to LangChain Labs’ write-up. For teams running agents in production, the surprise is where the gain came from: not from teaching the model to call more tools, but from training on answers alone, and the extra quality came with a latency bill.

What Happened

Chat LangChain, the company’s documentation assistant, now runs on a fine-tuned GLM 5.3 Flash trained on tasks built from its own production traces. An internal agent grouped those traces into usage patterns and turned them into benchmark tasks. The held-out set is 128 real user questions, scored 1 for a correct and complete answer, 0 for a shortfall and minus 0.5 for a confidently wrong one, averaged over eight attempts each.

The base model scored 0.679. LangChain compared three training methods. Supervised fine-tuning on a teacher’s runs added 0.052, but the student made 14.5 tool calls per question against 5 for the base, and median offline latency rose from 17 seconds to 75. GRPO added 0.037 with 42% more tool calls. Answer-only DPO added 0.056 with 33% more tool calls and 25% more turns, and that is the version LangChain deployed.

Why It Matters

The cost table is the argument for doing this at all. Per 1,000 questions, LangChain lists Sonnet 5.5 at $192, Opus 5.5 at $330, Gemini 3.5 Flash Lite at $20, base GLM at $9 and the fine-tune at $12. In an even production split scored with LangSmith online evaluations, users asked follow-up questions in 36% of fine-tune threads against 41% for Gemini. “The fine-tune beat Gemini on every quality measure while costing less to run,” the post says.

Speed was the cost. The fine-tune answered about twice as slowly as Gemini, and in its first days 18.7% of runs took longer than 30 seconds. A “keep answers concise” instruction cut that to 5.9% over the next six days, against 5.4% for base GLM. LangChain’s position is that “for a docs assistant, a wrong answer costs a user more than a few extra seconds.”

What This Means for Builders

The caveats matter as much as the scores. The benchmark is internal and was made harder on purpose: 78 of the 128 tasks were picked because the base model struggled with them. It runs in a mocked environment with model-based verifiers, and the results come from LangChain testing its own product. “Close to” GPT-6.1 Sol is LangChain’s phrase, and the gap is real.

The reusable part is the loop: production traces become tasks, tasks become a held-out benchmark, and the benchmark decides which training method ships. LangChain also found that the best of four base-model attempts scores 0.914, against about 0.7 for one, which suggests the base model often knows the answer and needs help choosing it. That pattern links to the trace-driven approach in our look at LangChain’s agent lake and improvement loop.

The So What

If you run a narrow agent on a frontier model and pay per question, build a held-out benchmark from your own traces before trying a fine-tune, start with answer-only preference training rather than imitating a teacher’s tool calls, and measure latency in production from day one, because LangChain’s quality gain arrived with responses about twice as slow.

Source: LangChain Blog

Content created with AI assistance and reviewed for accuracy.

💬

Join the conversation

Stack Insiders is our free community for readers who want to go deeper — share resources, ask questions, and connect with others across every vertical we cover.

Join Stack Insiders →

Newsletter coming soon.

Curated digests across AI, biohacking, photography, travel, and more. Be the first to know when we launch.