Langfuse, an open-source observability and evaluation platform for AI systems, conducted an experiment to understand how to build effective self-optimizing loops for AI applications by testing a minimal loop on a clear-cut classification task. The team used a single-label classification task on academic papers with GPT-4o mini as the agent and Claude Opus 4.8 as the optimizer, starting from a basic prompt and allowing the system to iteratively improve through error analysis. The experiment achieved a 15% accuracy improvement (from 68% to 83%) with most gains occurring in the first iteration, demonstrating that high-signal feedback (clear right/wrong evaluations) combined with sufficient training data enables effective auto-optimization, though the team emphasizes that most real-world applications require carefully designed domain-specific evaluators rather than generic metrics like correctness or helpfulness.
This case study from Langfuse explores the critical challenge of building self-optimizing AI systems that can continuously improve without excessive token consumption. The presentation, delivered in June 2026, addresses the growing trend of agentic loops and auto-improvement systems that gained significant attention earlier in the year through discussions from Boris Journey, Peter Steinberger, and Andrej Karpathy’s work on auto-research. However, the presenter Annabelle approaches this from a production-oriented perspective, acknowledging that while coding applications benefit from clear-cut target functions like “does the code compile,” most real-world AI applications in domains like medical compliance, healthcare, and customer service chatbots lack such obvious success criteria.
The fundamental insight driving this work is that teams investing heavily in capturing what they actually want through well-designed target functions and evaluators are the ones successfully upgrading their applications over time while shipping with confidence. To understand the role of target functions in self-optimization, Langfuse designed an experiment using the clearest possible target function they could find: a single-label classification task with deterministic right/wrong answers.
The experiment centered on a minimal self-optimization loop designed to classify academic papers from arXiv based on their titles and abstracts. The data architecture consisted of three distinct datasets: 200 items in a fit/training dataset, 100 in a validation dataset, and 300 in a test dataset. This traditional machine learning approach to data splitting was deliberate, aiming to prevent overfitting and ensure proper generalization.
The technical stack involved two different LLMs playing distinct roles. GPT-4o mini served as the classification agent, chosen specifically because Langfuse wanted to test how a smaller, more cost-effective model would perform in an auto-improvement context, given that frontier models have become expensive over time. The optimization process ran through Claude Code leveraging Claude Opus 4.8, one of the frontier models available in 2026, which was responsible for proposing prompt updates.
The base prompt was intentionally minimal: a flat list of labels with a simple instruction to classify papers. No reasoning guidance or contextual information was provided initially, as the team wanted to observe what the optimization system would naturally develop. The system also had access to the GPT-4o prompting guide and a task markdown file describing the loop structure.
The loop followed a structured step-by-step process encoded in a markdown file. First, it established a baseline by running the initial prompt on both the fit and validation datasets, scoring accuracy per item and overall. Then on the fit dataset, it performed detailed error analysis, examining which categories were frequently classified correctly, which label pairs were often confused, and analyzing the underlying abstracts and titles to identify patterns.
Based on this analysis, Claude Opus proposed updates targeting the biggest error category, published a new prompt version, and reran the classification. Critically, updates were only accepted if they improved performance on the validation dataset, not just the training set. This validation step prevented overfitting to the specific examples in the fit dataset.
The loop had two stopping criteria: either completing 15 runs or reaching 92% accuracy. Once stopped, a final evaluation run occurred on the previously unseen test dataset to assess true generalization capability. Notably, the optimization system was not given access to the test dataset during the improvement process, maintaining proper experimental rigor.
The results demonstrated both the power and limitations of self-optimization approaches. The system achieved a 15% absolute accuracy improvement, starting at 68% and reaching 83% on the fit dataset. Most remarkably, the first iteration alone produced a 10% improvement, with subsequent iterations adding only incremental gains. The final performance plateaued around 80-83%, and crucially, this generalized well to the test dataset at 80.2%, indicating the improvements were genuine and not merely overfitting.
The 80-83% plateau was initially surprising given the expectation of a “perfect” target function. However, deeper analysis revealed inherent ambiguity in the ground truth labels themselves. Authors had some creative freedom in choosing primary classification labels for their papers, meaning that alternative reasonable classifications existed that didn’t match the recorded ground truth. This introduced a natural ceiling on achievable accuracy.
Examining what the optimization system actually did reveals sophisticated prompt engineering. Rather than simply adding descriptions to the label list as a human might intuitively do, the system added a general classification approach explaining the model’s behavioral goals, provided guidance on deciding between similar classes, incorporated rules for handling confused patterns, and included specific examples for frequently misclassified item pairs. The system also implemented a preference for more specific labels over broad ones when ambiguity existed, recognizing implicit hierarchical structure in the label taxonomy.
The detailed reasoning trace from Claude Opus during that critical first 10% improvement iteration revealed the requirements for effective auto-optimization. The system identified 64 errors, determined dominating error patterns, found the biggest confusion between specific label pairs, and formulated a hypothesis about how proposed changes would address these patterns. Three factors enabled this success: clearly quantifiable and reliable failure modes with deterministic right/wrong answers, sufficient data volume with 200 training items ensuring each of the 10 labels appeared frequently enough to establish patterns, and high-signal feedback that was consistent across runs.
However, Langfuse acknowledges this experimental setup represents an idealized scenario. Most real-world applications lack deterministic yes/no target functions. LLM-as-judge evaluators are nondeterministic, meaning the same evaluation on the same output can produce different results across runs. Generic evaluation metrics like correctness, helpfulness, or hallucination scores, while popular in the market for good reason during early AI application development, provide relatively low signal for auto-optimization purposes.
These generic metrics typically use scales from zero to one or one to five, but proper usage requires defining what each numeric value means, which criteria must be met for each rating, and how those criteria apply across different contexts. Since this detailed calibration work is rarely done, these scores become inconsistent and context-dependent, making them poor targets for optimization loops.
Langfuse proposes translating the high-signal feedback approach to real-world applications through domain-specific evaluators. Instead of generic “correctness” metrics, they recommend binary checks like verifying that answers are based on the knowledge base by checking if information snippets appear in retrieved context from RAG systems. Brand voice consistency can be evaluated through specific checks such as confirming proper spelling of company names or verifying that names weren’t incorrectly translated into other languages.
Known failure mode categorization provides another effective evaluation approach, asking which of five specific failure types occurred rather than rating on a generic scale. These examples illustrate a broader principle: effective evaluators emerge from understanding domain-specific quality criteria, examining actual production data to identify what failures look like in practice, and encoding domain expertise into concrete, checkable conditions.
The volume of evaluation data matters significantly. While the experiment used 200 training examples, 100 validation examples, and 300 test examples, production applications should scale appropriately to their complexity. The validation set approach borrowed from traditional machine learning remains crucial for AI applications to prevent overfitting to specific examples while ensuring improvements generalize to new scenarios.
Langfuse recommends a systematic approach starting with expert collaboration. Domain experts should create concrete examples of desired outputs, participate in reviewing sample runs, and explain their reasoning for why certain decisions should be made differently in different contexts. This process surfaces implicit knowledge that experts assume is obvious but hasn’t been articulated, helps identify failure modes that matter in practice, and defines what “good” means in domain-specific terms.
Once initial production deployment occurs, ongoing human review remains essential even in automated systems. Engineering teams should regularly examine production data to understand the actual scope of usage, identify how usage patterns shift over time, spot changing failure modes, and recognize opportunities for feature expansion. This human-in-the-loop approach catches typical failure modes before customers encounter them and maintains system reliability as real-world usage evolves.
The entire system should be approached as a generalization challenge similar to traditional machine learning. The goal is building representative example sets that reflect expected production scenarios, implementing proper validation mechanisms to prevent overfitting, providing the optimization system with clear instructions and constraints, and building in escape hatches so the system can halt rather than burning tokens when hitting walls.
While the presentation comes from Langfuse, a company offering observability and evaluation tools, the experimental approach demonstrates genuine technical rigor through proper train/validation/test splits, transparent reporting of limitations like the ground truth ambiguity ceiling, and acknowledgment that their idealized classification scenario differs substantially from real-world complexity. The emphasis on domain expertise and high-signal evaluators represents sound engineering advice rather than merely product marketing.
However, several important considerations warrant balanced assessment. The experiment’s success relied on an unusually clean problem with only 10 classes and access to large amounts of labeled data, which many production applications lack. The cost dynamics deserve scrutiny: using Claude Opus 4.8 as the optimizer for a system meant to avoid “burning tokens” creates potential expense, especially at scale or with frequent optimization runs. The 15% improvement, while solid, required significant infrastructure and may not justify the complexity for all applications.
The nondeterminism problem in real-world evaluators extends beyond what the presentation addresses. Even well-designed domain-specific evaluators can suffer from inconsistency when implemented as LLM judges, potentially requiring multiple evaluation runs and statistical approaches. The human-in-the-loop requirements for reviewing data, defining evaluators, and validating improvements remain substantial, creating ongoing operational overhead that may limit the “auto” in auto-optimization for many teams.
This work illustrates several important patterns for operating LLMs in production environments. The emphasis on observability through detailed error analysis, pattern identification, and performance tracking across different dataset splits reflects mature MLOps practices adapted to the LLM context. The dual-model architecture with a smaller model for inference and a frontier model for optimization represents a practical cost management strategy common in production LLM systems.
The validation-gated improvement acceptance demonstrates essential safeguards for production AI systems, preventing degradation from changes that improve on training data but don’t generalize. The structured loop with clear stopping criteria, escape hatches, and human oversight points reflect realistic production constraints around cost control, reliability requirements, and regulatory or safety considerations.
The focus on encoding domain expertise into evaluators rather than relying on generic metrics represents a maturation of LLMOps practices beyond initial proof-of-concept deployments. This aligns with broader industry movement toward domain-specific solutions as AI applications move from experimentation to production deployment. The presentation’s timing in June 2026, referencing the surge of interest in agentic loops earlier that year, positions this work within the evolution of production AI systems from static prompts to dynamic, self-improving systems.
The experimental methodology itself provides a template for teams wanting to understand auto-optimization capabilities before deploying them in production: start with simplified problems having clear-cut success criteria, implement proper data splits to measure generalization, use detailed logging and tracing to understand optimization decisions, and gradually increase complexity while monitoring whether improvements continue to generalize. This de-risking approach helps teams build confidence in auto-optimization techniques before applying them to more ambiguous, higher-stakes production scenarios.
Medable developed Agent Studio, a comprehensive platform for deploying AI agents in clinical trial operations to address the lengthy drug approval process that currently takes over 10 years. The platform enables both internal teams and customers to build configurable multi-agent systems that tackle problems like document classification in electronic trial master files and clinical research monitoring across multiple data systems. By taking a platform-first approach with support for model-agnostic agents, RAG knowledge integration, MCP connectors, workflow functionality, and robust evaluation frameworks, Medable has deployed multiple agentic applications that help clinical research associates process over 80,000 documents per year and monitor data across 13+ disparate systems, with the ambitious goal of reducing clinical trial timelines from 10 years to one year.
Snorkel developed a specialized benchmark dataset for evaluating AI agents in insurance underwriting, leveraging their expert network of Chartered Property and Casualty Underwriters (CPCUs). The benchmark simulates an AI copilot that assists junior underwriters by reasoning over proprietary knowledge, using multiple tools including databases and underwriting guidelines, and engaging in multi-turn conversations. The evaluation revealed significant performance variations across frontier models (single digits to ~80% accuracy), with notable error modes including tool use failures (36% of conversations) and hallucinations from pretrained domain knowledge, particularly from OpenAI models which hallucinated non-existent insurance products 15-45% of the time.
Digits, a company providing automated accounting services for startups and small businesses, implemented production-scale LLM agents to handle complex workflows including vendor hydration, client onboarding, and natural language queries about financial books. The company evolved from a simple 200-line agent implementation to a sophisticated production system incorporating LLM proxies, memory services, guardrails, observability tooling (Phoenix from Arize), and API-based tool integration using Kotlin and Golang backends. Their agents achieve a 96% acceptance rate on classification tasks with only 3% requiring human review, handling approximately 90% of requests asynchronously and 10% synchronously through a chat interface.