Self-Optimizing Classification Loops with Domain Expertise and High-Signal Evaluation

Annabell Schäfer18 Jul 2026

Problem

Teams copy the auto-improvement "loops" that work for coding agents, where a clear target exists: the code compiles or it does not. In medicine, compliance and chatbots no such yes/no target exists, and any target given to an agent is incomplete. A loop with a vague target spends tokens without improving the application. Generic LLM-judge scores such as correctness on a 0 to 1 scale vary between runs.

Example from the article: Langfuse tested a minimal loop on single-label classification of arXiv papers into 10 labels, the clearest target they could find, to see what a loop needs.

Solution in brief

Run the loop only against a target that scores every item as right or wrong, and split data into fit, validation and test sets. An optimizer model reads the errors on the fit set, proposes one prompt change per round and keeps it only if validation accuracy also improves. For real applications, build such yes/no evaluators together with domain experts.

Questions this case answers
  • How to automatically improve a prompt-based classifier against labeled data so that gains generalize to unseen items
  • How to define a high-signal target function for an automated improvement loop when no binary success check such as compilation exists
  • How to automatically improve an LLM classifier prompt against a labeled dataset without overfitting?
  • How to stop an auto-improvement loop from burning tokens without improving the application?

Tools and methods

  • Prompt optimization loop — a frontier model rewrites the prompt of a cheap model from error analysis
  • Fit / validation / test split — 200 / 100 / 300 items to detect overfitting
  • Few-shot examples and decision rules — what the optimizer added to the prompt
  • Yes/no evaluators — replace scaled LLM judges
  • Langfuse — prompt management, datasets and evaluation runs
  • Claude Code — runs the optimizer model with a task.md describing the loop
Continue reading — it's free

Google or a one-time email code. No password.