Autoresearch Loops in AI
2026-07-024 turns83,316 charsgpt-5-3-mini
Summary
The user requested a blog post about autoresearch loops in AI followed by an addendum with code examples.
Messages
rewrite the following into one blog post: ---
book_reference: true
canonical_url: /blog/2026-07-02-building-autonomous-sovereign-ai-with-autoresearch-loops-and-fine-tuned-expert-models
categories:
- AI Architecture
- Sovereign AI
- Agent Systems
date: 07-02-2026
description: 'How to build self-improving AI systems using autoresearch loops, agent recipes, and domain-specific fine-tuning with open-source tools. A complete implementation guide connecting the latest research from Introspection, Bridgewater AIA Labs, and Thinking Machines Lab.'
image: /images/ComfyUI_00206_.png
layout: post
tags:
- autonomous-agents
- sovereign-ai
- autoresearch
- fine-tuning
- local-first
- open-source
- agent-recipes
- reinforcement-learning
- sovereign-architecture
- local-llms
- ollama
- smolagents
- langgraph
- deerflow
title: 'Building Autonomous Sovereign AI: How Autoresearch Loops and Expert Fine-Tuning Create Self-Improving Local AI Systems'
wiki_references: ["autonomous-agents", "fine-tuning", "knowledge-graphs", "local-llms", "ollama", "rag", "reinforcement-learning", "sovereign-ai"]
---
# Building Autonomous Sovereign AI: How Autoresearch Loops and Expert Fine-Tuning Create Self-Improving Local AI Systems
**Date:** July 2, 2026
## Introduction: The Paradigm Shift from Models to Loops
We're witnessing a fundamental transformation in how we build AI systems. The frontier models we depend on for complex tasks are hitting a wall—not because they're less capable, but because they lack the domain expertise that comes from experience. As demonstrated by Bridgewater AIA Labs' research on replicating expert judgment in financial tasks, even state-of-the-art models like GPT-5.5 and Claude Opus 4.8 achieve only 78% accuracy on seemingly simple information filtering tasks that investors perform effortlessly.
Meanwhile, Introspection co-founder Roland Gavrilescu has revealed the emerging pattern: **the loop is the product**. We've moved from focusing on models, to harnesses, and now to feedback loops where agents help maintain and improve the system itself.
This guide bridges these two converging paradigms. You'll learn how to:
1. Build **autoresearch loops** that continuously improve your AI system
2. Create **agent recipes** that encode human expertise in portable formats
3. Fine-tune **open-weight models** to outperform frontier models on domain-specific tasks
4. Architect **sovereign AI systems** that run locally with complete data privacy
The tools we'll use are all open-source. The architecture will be fully local-first. And the result will be an AI system that gets better over time without costing a fortune in API calls.
---
## Part 1: Understanding Autoresearch Loops
### The Three Patterns of Self-Improving Systems
According to Gavrilescu's framework at Introspection, there are three key patterns that form the blueprint for autonomous software factories:
#### Pattern 1: The Loop Is the Product
Traditional AI systems are static—train a model, deploy it, move on. Autoresearch systems are different. They contain feedback mechanisms that allow agents to improve the system itself over time. The challenge is designing the right signals so agents can take on more work without generating more slop.
**Why this matters for you:** If you're building AI agents today, you're building a product that will stagnate. The systems that win are those that improve themselves through feedback loops.
#### Pattern 2: Agent Recipes
Think of agent recipes like cooking recipes, but for AI systems. Just as a data recipe describes how much data from different domains should be baked into a model, an agent recipe describes:
- How your harness works with different models
- The evals you use to measure performance
- The judges you've created to evaluate outputs
- The human expertise you've captured
- The failures that led to new evals
The idea comes from a powerful insight: if you had access to Devin's codebase tomorrow, the code alone wouldn't tell you how the team arrived at the current version. You'd want to understand the failures, mistakes, and decisions that informed it. **Recipes capture that process.**
#### Pattern 3: Optimization for Quality AND Cost
The final pattern is about what we optimize for. Companies like Cursor and Cognition have shown these products can work. The next stage is making them more accessible, faster, and cheaper—gradually distilling frontier model capabilities into systems you own and customize for your environment.
### The Inner Loop and Outer Loop
In practice, autoresearch systems have two loops:
- **Inner Loop:** The primary system doing the work (e.g., an agent answering questions)
- **Outer Loop:** A feedback system where agents help maintain and improve the inner loop using feedback signals, evals, and human input
This is where the magic happens. The outer loop monitors the inner loop's performance, identifies failures, creates new evals, refines the prompts, and iterates—all without constant human intervention.
---
## Part 2: The Expert Judgment Problem
### Why Frontier Models Struggle with Domain Tasks
Before we build the loops, we need to understand the problem they solve. Bridgewater AIA Labs tested frontier models on six information filtering tasks drawn from investors' daily workflows:
1. **Financial Article Relevancy** – Classifying whether articles are relevant to investment professionals
2. **Central Bank Document Relevancy** – Identifying interest rate signals in central bank documents
3. **Generic Document Relevancy** – Determining if documents help answer specific questions
4. **Ad Hoc Content Labeling** – Distinguishing recurring boilerplate from unique analysis
5. **Document Truncation** – Finding where boilerplate content begins
6. **Email Truncation** – Identifying boilerplate in emails
The results were striking: frontier models averaged only ~50% accuracy. Even with expert prompt engineering, they plateaued below 80%—the threshold investors need to trust a system for daily workflow.
**The key insight:** "An explicit prompt can only convey the intuition an expert is able to put into words, while the judgments that matter most are often the hardest to articulate."
This is why fine-tuning works better than prompting. The training process lets the model develop its own judgment rather than contorting expert intuition into static prompts.
### The Training Recipe That Works
Bridgewater's team used a sophisticated training recipe on open-weight models that dramatically outperformed frontier models:
| Component | Accuracy Improvement |
| Base Model (Qwen3-235B) | 44.8% accuracy |
| + GRPO (critic-free RL) | 73.48% (+28.7%) |
| + Interleaved Batching | +12.1% over fully mixed |
| + CISPO Loss with Asymmetric Clipping | +10.1% over importance sampling |
| + On-Policy Distillation (OPD) | +3.1% over frozen teacher |
| **Final Trained Model** | **84.7% accuracy** |
The trained model made **29.8% fewer mistakes** than the best frontier models while being **13.8x cheaper** per task due to its smaller size.
This is the vision of **differentiated intelligence**—models tuned for specific organizational needs that outperform general-purpose frontier models.
---
## Part 3: Building Your Own Autoresearch System
Now let's get into the implementation. We'll build a system that:
1. Uses **open-source tools** (Ollama, Smolagents, LangGraph)
2. Runs **locally** (no cloud dependencies)
3. Implements **autoresearch loops** (self-improving architecture)
4. Can be **fine-tuned** on domain-specific tasks
### Architecture Overview
```
┌─────────────────────────────────────────────────────────────┐
│ Sovereign AI Architecture │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
│ │ Agents │───→│ Inner Loop │───→│ Output │ │
│ │ (Smolagents│ │ (Task │ │ (User-facing │ │
│ │ + Ollama) │ │ Execution) │ │ Response) │ │
│ └─────────────┘ └──────────────┘ └───────────────┘ │
│ │ │ │ │
│ │ ↓ │ │
│ │ ┌──────────────┐ │ │
│ │ │ Evals & │ │ │
│ │ │ Judges │ │ │
│ │ │ (Quality │ │ │
│ │ │ Gates) │ │ │
│ │ └──────────────┘ │ │
│ │ │ │ │
│ ↓ ↓ ↓ │
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
│ │ Agent │ │ Outer Loop │ │ Agent │ │
│ │ Recipes │ │ (Feedback & │ │ Training │ │
│ │ (Portable │ │ Self- │ │ Pipeline │ │
│ │ Format) │ │ Improvement)│ │ (Fine-tuning) │ │
│ └─────────────┘ └──────────────┘ └───────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐│
│ │ Knowledge Graph (Neo4j) + ChromaDB ││
│ │ Dynamic Persona MoE RAG System ││
│ └─────────────────────────────────────────────────────────┘│
│ │
└─────────────────────────────────────────────────────────────┘
```
### Step 1: Set Up Your Local AI Infrastructure
First, let's set up the foundation using Ollama for local LLM inference and DeerFlow 2.0's SuperAgent harness for agent orchestration.
```bash
# Install Ollama (local LLM runtime)
curl -fsSL https://ollama.com/install.sh | sh
# Pull models for different tasks
ollama pull qwen2.5:7b # Fast reasoning model
ollama pull llama3.1:8b # General purpose
ollama pull mistral:7b # Code generation
# Install DeerFlow 2.0 (sovereign AI agent system)
git clone https://github.com/kliewerdaniel/DeerFlow.git
cd DeerFlow
pip install -r requirements.txt
```
### Step 2: Build Your Agent Recipes
Agent recipes are portable containers that encode human expertise. Let's create a recipe structure:
```python
# agent_recipe.py - Agent Recipe Template
from dataclasses import dataclass, field
from typing import List, Dict, Any, Callable
from enum import Enum
class RecipeVersion:
v1 = "1.0"
@dataclass
class Evaluator:
name: str
function: Callable[[str, str], float]
description: str
threshold: float = 0.8
@dataclass
class HumanExpertise:
domain: str
rules: List[str]
examples: List[Dict[str, str]]
@dataclass
class AgentRecipe:
"""
Portable container for encoding human expertise.
Recipes capture the process: baseline → failures → new evals → improvements.
"""
name: str
version: str = RecipeVersion.v1
description: str = ""
# The harness configuration
model_config: Dict[str, Any] = field(default_factory=dict)
# Evaluators and judges
evalutors: List[Evaluator] = field(default_factory=list)
# Human expertise captured
expert_knowledge: HumanExpertise = None
# Training data for fine-tuning
training_data_path: str = ""
# Feedback mechanisms
feedback_thresholds: Dict[str, float] = field(default_factory=dict)
# Iteration history (captures failures and decisions)
iteration_history: List[Dict[str, Any]] = field(default_factory=list)
def add_evaluation(self, evaluator: Evaluator):
"""Add a new evaluation metric to the recipe"""
self.evalutors.append(evaluator)
def add_feedback_iteration(self, iteration_data: Dict):
"""Record an iteration: what failed, what was tried, what worked"""
self.iteration_history.append(iteration_data)
def to_dict(self) -> Dict:
"""Serialize recipe for portability"""
return {
"name": self.name,
"version": self.version,
"description": self.description,
"evalutors": [e.__dict__ for e in self.evalutors],
"expert_knowledge": self.expert_knowledge.__dict__ if self.expert_knowledge else None,
"iteration_history": self.iteration_history,
"created_at": datetime.now().isoformat()
}
# Example: Financial Expert Recipe
financial_recipe = AgentRecipe(
name="financial-article-classifier",
description="Classifies financial articles for investment relevance",
model_config={"model": "qwen2.5:7b", "temperature": 0.3},
evalutors=[
Evaluator(
name="relevance_score",
function=lambda text, context: 0.95, # Placeholder
description="Scores article relevance to investment decisions",
threshold=0.8
),
Evaluator(
name="significance_score",
function=lambda text, context: 0.9, # Placeholder
description="Assesses broad significance beyond narrow relevance"
)
],
expert_knowledge=HumanExpertise(
domain="financial-investment",
rules=[
"Classify into three categories: relevant & interesting, relevant but uninteresting, irrelevant",
"Consider macroeconomic impact, not just financial relevance",
"Small IPOs may be relevant but not interesting to macro investors",
"Geopolitical events only matter if they have direct market impact"
],
examples=[
{
"text": "Trump insists Greenland is his",
"label": "irrelevant",
"reasoning": "Geopolitical topic but lacks market significance"
},
{
"text": "US stocks close sharply lower after Trump threatens new China tariffs",
"label": "relevant & interesting",
"reasoning": "Direct market impact with macroeconomic implications"
}
]
)
)
```
### Step 3: Implement the Autoresearch Loop
Now let's build the feedback loop that continuously improves the system:
```python
# autoresearch_loop.py - Self-Improving Agent System
from deerflow.agent import SuperAgent
from deerflow.memory import PersistentMemory
from deerflow.eval import Evaluator
import json
import logging
class AutoresearchLoop:
"""
Implements the three-pattern autoresearch architecture:
1. The loop is the product
2. Agent recipes encode expertise
3. Optimize for quality AND cost
"""
def __init__(self, recipe: AgentRecipe):
self.recipe = recipe
self.agent = SuperAgent() # DeerFlow's SuperAgent harness
self.memory = PersistentMemory()
self.evaluators = Evaluator()
self.iteration_count = 0
self.performance_history = []
def execute_task(self, task: str, context: str) -> str:
"""Inner loop: Execute the primary task"""
response = self.agent.run(
task=task,
context=context,
model=self.recipe.model_config["model"]
)
# Evaluate output quality
quality_score = self.evaluate_output(task, response)
return {
"response": response,
"quality_score": quality_score,
"timestamp": datetime.now().isoformat()
}
def evaluate_output(self, task: str, output: str) -> float:
"""Evaluate output against recipe's evaluators"""
scores = []
for evaluator in self.recipe.evalutors:
score = evaluator.function(output, task)
scores.append(score)
return sum(scores) / len(scores) if scores else 0.0
def identify_failures(self, results: List[Dict]) -> List[Dict]:
"""Outer loop: Identify failures that need attention"""
failures = []
for result in results:
if result["quality_score"] < self.recipe.feedback_thresholds.get("min_quality", 0.8):
failures.append({
"task": result["task"],
"output": result["output"],
"quality_score": result["quality_score"],
"suggested_improvement": self.analyze_failure(result)
})
return failures
def analyze_failure(self, failure: Dict) -> str:
"""Analyze why a failure occurred and suggest improvements"""
# This could use a separate agent to analyze failures
# or check against historical patterns
return f"Suggested improvement for: {failure['task'][:50]}..."
def create_new_evals(self, failures: List[Dict]) -> List[Evaluator]:
"""Outer loop: Create new evaluators based on failure patterns"""
new_evalutors = []
# Group failures by type
failure_patterns = self.group_failure_patterns(failures)
for pattern, count in failure_patterns.items():
if count >= 3: # Only create evals for recurring failures
new_evalutor = Evaluator(
name=f"pattern_{pattern}",
function=self.create_pattern_evaluator(pattern),
description=f"Evaluates {pattern} pattern",
threshold=0.7
)
new_evalutors.append(new_evalutor)
return new_evalutors
def group_failure_patterns(self, failures: List[Dict]) -> Dict[str, int]:
"""Group failures by pattern to identify recurring issues"""
patterns = {}
for failure in failures:
pattern = failure["suggested_improvement"][:50] # Simplified
patterns[pattern] = patterns.get(pattern, 0) + 1
return patterns
def update_recipe(self, new_evalutors: List[Evaluator], iteration_data: Dict):
"""Update the recipe with new knowledge"""
for evaluator in new_evalutors:
self.recipe.add_evaluation(evaluator)
self.recipe.add_feedback_iteration(iteration_data)
self.iteration_count += 1
def run_autoresearch_cycle(self, tasks: List[Dict]):
"""Run a complete autoresearch cycle"""
logging.info(f"Starting autoresearch cycle {self.iteration_count + 1}")
# Inner loop: Execute tasks
results = [self.execute_task(t["task"], t.get("context", "")) for t in tasks]
# Outer loop: Identify failures
failures = self.identify_failures(results)
# Outer loop: Create new evaluators
new_evalutors = self.create_new_evals(failures)
# Update recipe
if new_evalutors:
self.update_recipe(
new_evalutors,
{
"iteration": self.iteration_count + 1,
"tasks_processed": len(results),
"failures_found": len(failures),
"new_evals_created": len(new_evalutors)
}
)
# Record performance
avg_quality = sum(r["quality_score"] for r in results) / len(results)
self.performance_history.append({
"iteration": self.iteration_count,
"avg_quality": avg_quality,
"num_evalutors": len(self.recipe.evalutors)
})
logging.info(f"Cycle complete. Quality: {avg_quality:.3f}, Evals: {len(self.recipe.evalutors)}")
return results
```
### Step 4: Build the Fine-Tuning Pipeline
Now let's implement the fine-tuning pipeline that allows the system to learn from expert annotations. This uses techniques from the Bridgewater AIA Labs research:
```python
# fine_tuning_pipeline.py - Domain-Specific Model Training
import torch
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
TrainingArguments,
Trainer,
DataCollatorForSeq2Seq
)
from datasets import Dataset
from peft import LoraConfig, get_peft_model
import json
class ExpertFineTuningPipeline:
"""
Fine-tuning pipeline implementing:
- GRPO (critic-free RL)
- Interleaved batching
- CISPO loss with asymmetric clipping
- On-policy distillation (OPD)
"""
def __init__(self, base_model_name: str = "Qwen/Qwen2.5-7B-Instruct"):
self.base_model_name = base_model_name
self.model = None
self.tokenizer = None
self.training_data = None
def load_base_model(self):
"""Load the base model"""
print(f"Loading base model: {self.base_model_name}")
self.tokenizer = AutoTokenizer.from_pretrained(self.base_model_name)
self.model = AutoModelForCausalLM.from_pretrained(
self.base_model_name,
torch_dtype=torch.float16,
device_map="auto"
)
return self
def prepare_training_data(self, data_path: str):
"""
Load and prepare training data.
Data format: List of {
"instruction": "...",
"input": "...",
"output": "...",
"quality_score": float
}
"""
with open(data_path, 'r') as f:
data = json.load(f)
# Convert to HuggingFace Dataset
self.training_data = Dataset.from_list(data)
# Tokenize
def tokenize_function(examples):
inputs = self.tokenizer(
examples["instruction"] + examples["input"],
truncation=True,
max_length=2048,
padding="max_length"
)
labels = self.tokenizer(
examples["output"],
truncation=True,
max_length=2048
)["input_ids"]
# Replace -100 (padding) with actual labels
labels = [(l if l != self.tokenizer.pad_token_id else -100)
for l in labels]
inputs["labels"] = labels
return inputs
self.training_data = self.training_data.map(
tokenize_function,
batched=True,
remove_columns=self.training_data.column_names
)
return self
def train_with_grpo(self, output_dir: str = "./trained_model"):
"""
Train with GRPO (critic-free reinforcement learning).
This is the foundation that gives massive performance gains:
Qwen Base: 44.8% → Qwen + GRPO: 73.48%
"""
# Configure LoRA for efficient fine-tuning
lora_config = LoraConfig(
r=16,
lora_alpha=32,
target_modules=["q_proj", "v_proj"],
lora_dropout=0.05,
bias="none",
task_type="CAUSAL_LM"
)
self.model = get_peft_model(self.model, lora_config)
self.model.print_trainable_parameters()
# Training arguments
training_args = TrainingArguments(
output_dir=output_dir,
learning_rate=1e-4,
per_device_train_batch_size=4,
gradient_accumulation_steps=4,
num_train_epochs=3,
warmup_steps=100,
logging_steps=10,
save_steps=500,
eval_steps=500,
evaluation_strategy="steps",
save_strategy="steps",
load_best_model_at_end=True,
fp16=True,
bf16=False
)
# Data collator
data_collator = DataCollatorForSeq2Seq(
tokenizer=self.tokenizer,
padding=True,
max_length=2048
)
# Train
trainer = Trainer(
model=self.model,
args=training_args,
train_dataset=self.training_data,
data_collator=data_collator
)
train_result = trainer.train()
# Save the model
self.model.save_pretrained(output_dir)
self.tokenizer.save_pretrained(output_dir)
return train_result
def apply_interleaved_batching(self, task_datasets: Dict[str, Dataset]):
"""
Apply interleaved batching for multi-task training.
Results: +12.1% accuracy over fully mixed batches
"""
# Create interleaved dataset
interleaved = []
datasets = list(task_datasets.values())
dataset_names = list(task_datasets.keys())
# Round-robin interleaving
max_size = max(len(ds) for ds in datasets)
for i in range(max_size):
for ds, name in zip(datasets, dataset_names):
if i < len(ds):
interleaved.append({**ds[i], "task": name})
return Dataset.from_list(interleaved)
def apply_on_policy_distillation(self, teacher_model_path: str):
"""
Apply on-policy distillation (OPD) with teacher promotion.
Every 20 steps, promote the current checkpoint to the teacher
only if validation accuracy has reached a new high.
Results: +3.1% over frozen base-model teacher
"""
# Load teacher model
teacher = AutoModelForCausalLM.from_pretrained(teacher_model_path)
# Custom training loop with teacher updates
# (Implementation details for the training loop)
pass
def evaluate(self, test_data_path: str) -> Dict[str, float]:
"""Evaluate the trained model"""
# Load test data
with open(test_data_path, 'r') as f:
test_data = json.load(f)
# Evaluate
correct = 0
total = len(test_data)
for item in test_data:
prediction = self.predict(item["instruction"], item["input"])
if prediction == item["output"]:
correct += 1
accuracy = correct / total
return {
"accuracy": accuracy,
"total_samples": total,
"correct": correct
}
```
### Step 5: Implement the Sovereign Architecture
Now let's integrate everything into a complete sovereign AI architecture that runs locally with complete data privacy:
```python
# sovereign_ai_system.py - Complete Integration
from deerflow.agent import SuperAgent
from deerflow.memory import PersistentMemory
from deerflow.eval import Evaluator
from knowledge_graph import KnowledgeGraph
from llama_cpp import Llama
import json
class SovereignAISystem:
"""
Complete sovereign AI system integrating:
- Autoresearch loops
- Agent recipes
- Domain-specific fine-tuning
- Local-first architecture
- Dynamic Persona MoE RAG
"""
def __init__(self, config_path: str = "config.yaml"):
self.config = self.load_config(config_path)
self.agent = SuperAgent()
self.memory = PersistentMemory()
self.knowledge_graph = KnowledgeGraph()
self.recipes = {}
self.fine_tuning_pipeline = None
def load_recipe(self, recipe: AgentRecipe):
"""Load an agent recipe into the system"""
self.recipes[recipe.name] = recipe
self.memory.store_recipe(recipe.to_dict())
def process_document(self, recipe_name: str, document: str, context: str = "") -> str:
"""Process a document using a specific agent recipe"""
recipe = self.recipes.get(recipe_name)
if not recipe:
raise ValueError(f"Recipe {recipe_name} not found")
# Execute the inner loop
result = self.autoresearch_loop.execute_task(
task=document,
context=context
)
# Store the result
self.memory.store_result({
"recipe": recipe_name,
"document": document[:100],
"result": result,
"timestamp": datetime.now().isoformat()
})
return result
def run_autoresearch_cycle(self):
"""Run a complete autoresearch cycle"""
# Get recent results from memory
recent_results = self.memory.get_recent_results(limit=100)
# Execute the autoresearch loop
results = self.autoresearch_loop.run_autoresearch_cycle(recent_results)
return results
def train_domain_model(self, data_path: str, output_dir: str):
"""Train a domain-specific model"""
pipeline = ExpertFineTuningPipeline()
pipeline.load_base_model()
pipeline.prepare_training_data(data_path)
# Apply advanced training techniques
pipeline.train_with_grpo(output_dir)
# Store the trained model reference
self.memory.store_trained_model({
"path": output_dir,
"data_source": data_path,
"trained_at": datetime.now().isoformat()
})
return output_dir
def query_with_expert_judgment(self, query: str, domain: str = "general") -> str:
"""
Query the system with domain-specific expert judgment.
Uses the trained model and knowledge graph to provide
answers with expert-level taste and judgement.
"""
# Retrieve relevant knowledge
context = self.knowledge_graph.query(query, domain)
# Generate response using the appropriate model
response = self.agent.run(
task=query,
context=context,
model=self.get_best_model_for_domain(domain)
)
return response
def get_best_model_for_domain(self, domain: str) -> str:
"""Get the best model for a specific domain"""
# Return the fine-tuned model for the domain if available
trained_models = self.memory.get_trained_models()
for model_info in trained_models:
if model_info["domain"] == domain:
return model_info["path"]
# Fallback to base model
return self.config.get("default_model", "qwen2.5:7b")
# Configuration example
CONFIG = {
"default_model": "qwen2.5:7b",
"autoresearch": {
"cycle_interval": "1h",
"min_quality_threshold": 0.8,
"max_iterations": 100
},
"fine_tuning": {
"base_model": "Qwen/Qwen2.5-7B-Instruct",
"learning_rate": 1e-4,
"batch_size": 4
}
}
```
### Step 6: Set Up the Knowledge Graph and RAG System
To complete the sovereign architecture, we integrate a knowledge graph and RAG system that provides context for the agent's decisions:
```bash
# Install Neo4j for knowledge graph
docker run -d \
--name neo4j \
-p 7474:7474 -p 7687:7687 \
-e NEO4J_AUTH=neo4j/password \
neo4j:5
# Install ChromaDB for vector storage
pip install chromadb
# Install LangChain for RAG
pip install langchain langchain-community langchain-ollama
```
```python
# rag_system.py - Dynamic Persona MoE RAG
from langchain_community.vectorstores import Chroma
from langchain_community.embeddings import OllamaEmbeddings
from langchain_community.llms import Ollama
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.graphs import Neo4jGraph
class DynamicPersonaMoERAG:
"""
Dynamic Persona Mixture-of-Experts RAG System.
Features:
- Dynamic personas that evolve based on context
- Mixture of experts for different domains
- Knowledge graph integration for structured reasoning
- Memory systems for persistent learning
"""
def __init__(self):
self.embeddings = OllamaEmbeddings(model="nomic-embed-text")
self.llm = Ollama(model="qwen2.5:7b")
self.vectorstore = Chroma(
collection_name="sovereign_ai",
embedding_function=self.embeddings
)
self.graph = Neo4jGraph(
url="bolt://localhost:7687",
username="neo4j",
password="password"
)
self.personas = {}
self.experts = {}
def add_document(self, text: str, metadata: Dict = None):
"""Add a document to the knowledge base"""
splitter = RecursiveCharacterTextSplitter(
chunk_size=1000,
chunk_overlap=200
)
chunks = splitter.split_text(text)
self.vectorstore.add_texts(chunks, metadata=metadata or {})
# Extract and store knowledge graph relationships
self.extract_knowledge(text)
def extract_knowledge(self, text: str):
"""Extract knowledge graph relationships from text"""
# Use LLM to extract entities and relationships
prompt = f"""
Extract entities and relationships from this text.
Return as a list of triples (subject, predicate, object).
Text: {text}
"""
response = self.llm.invoke(prompt)
# Parse response and add to graph
# (Implementation details for parsing and adding triples)
def create_expert_persona(self, name: str, domain: str, expertise: str):
"""Create a new expert persona"""
persona = {
"name": name,
"domain": domain,
"expertise": expertise,
"context": f"You are an expert in {domain}. {expertise}",
"documents": []
}
self.personas[name] = persona
self.experts[domain] = name
return persona
def query(self, question: str, top_k: int = 5) -> Dict:
"""
Query the system with dynamic persona routing.
1. Determine the appropriate expert persona
2. Retrieve relevant documents
3. Generate response with expert context
"""
# Route to appropriate expert
expert = self.route_to_expert(question)
# Retrieve relevant documents
docs = self.vectorstore.similarity_search(
question,
k=top_k,
filter={"expert": expert["name"]}
)
# Generate response with expert context
context = "\n\n".join([doc.page_content for doc in docs])
prompt = f"""
{expert['context']}
Context: {context}
Question: {question}
Answer:
"""
response = self.llm.invoke(prompt)
return {
"answer": response,
"expert": expert["name"],
"sources": [doc.metadata for doc in docs],
"confidence": self.calculate_confidence(docs)
}
def route_to_expert(self, question: str) -> Dict:
"""Route question to the appropriate expert persona"""
# Simple routing based on keywords
for domain, persona in self.personas.items():
if any(keyword.lower() in question.lower()
for keyword in persona["domain"].split()):
return persona
# Default to general expert
return self.personas.get("general", {"name": "general", "domain": "general"})
def calculate_confidence(self, docs) -> float:
"""Calculate confidence score for the answer"""
if not docs:
return 0.0
# Simple confidence based on number of relevant documents
return min(1.0, len(docs) / 5.0)
def learn_from_feedback(self, question: str, answer: str,
correct: bool, feedback: str = None):
"""Learn from user feedback to improve the system"""
# Store feedback in memory
self.memory.store_feedback({
"question": question,
"answer": answer,
"correct": correct,
"feedback": feedback,
"timestamp": datetime.now().isoformat()
})
if not correct and feedback:
# Update the relevant persona's knowledge
self.update_expert_knowledge(question, feedback)
def update_expert_knowledge(self, question: str, feedback: str):
"""Update an expert's knowledge based on feedback"""
# Find the relevant expert and update their understanding
expert = self.route_to_expert(question)
# Add the feedback as a learning example
learning_example = {
"question": question,
"feedback": feedback,
"expert": expert["name"],
"learned_at": datetime.now().isoformat()
}
if expert["name"] not in self.personas:
self.personas[expert["name"]] = {
"name": expert["name"],
"domain": expert["domain"],
"expertise": "",
"context": f"You are an expert in {expert['domain']}.",
"documents": [],
"learning_examples": []
}
self.personas[expert["name"]]["learning_examples"].append(learning_example)
```
---
## Part 4: Production Deployment and Monitoring
### Monitoring the Autoresearch Loop
To ensure your autoresearch system is working correctly, implement comprehensive monitoring:
```python
# monitoring.py - System Monitoring
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
class AutoresearchMonitor:
"""Monitor the autoresearch system's performance over time"""
def __init__(self):
self.metrics = {
"quality_scores": [],
"iteration_counts": [],
"evaluator_counts": [],
"task_counts": []
}
def record_iteration(self, quality: float, num_evals: int, num_tasks: int):
"""Record metrics for an iteration"""
self.metrics["quality_scores"].append(quality)
self.metrics["iteration_counts"].append(len(self.metrics["quality_scores"]))
self.metrics["evaluator_counts"].append(num_evals)
self.metrics["task_counts"].append(num_tasks)
def generate_report(self) -> Dict:
"""Generate a comprehensive performance report"""
return {
"total_iterations": len(self.metrics["iteration_counts"]),
"avg_quality": sum(self.metrics["quality_scores"]) / len(self.metrics["quality_scores"]) if self.metrics["quality_scores"] else 0,
"improvement_trend": self.calculate_trend(),
"current_evalutors": self.metrics["evaluator_counts"][-1] if self.metrics["evaluator_counts"] else 0,
"total_tasks_processed": sum(self.metrics["task_counts"])
}
def calculate_trend(self) -> str:
"""Calculate the quality improvement trend"""
if len(self.metrics["quality_scores"]) < 2:
return "insufficient_data"
scores = self.metrics["quality_scores"]
recent_avg = sum(scores[-5:]) / min(5, len(scores))
earlier_avg = sum(scores[:5]) / min(5, len(scores))
if recent_avg > earlier_avg:
return "improving"
elif recent_avg < earlier_avg:
return "degrading"
else:
return "stable"
def generate_chart(self, output_path: str = "performance_chart.png"):
"""Generate a performance chart"""
fig, axes = plt.subplots(2, 2, figsize=(12, 10))
# Quality over time
axes[0, 0].plot(self.metrics["iteration_counts"], self.metrics["quality_scores"])
axes[0, 0].set_xlabel('Iteration')
axes[0, 0].set_ylabel('Quality Score')
axes[0, 0].set_title('System Quality Over Time')
# Evaluator count over time
axes[0, 1].plot(self.metrics["iteration_counts"], self.metrics["evaluator_counts"])
axes[0, 1].set_xlabel('Iteration')
axes[0, 1].set_ylabel('Number of Evaluators')
axes[0, 1].set_title('Evaluator Count Over Time')
# Task count over time
axes[1, 0].plot(self.metrics["iteration_counts"], self.metrics["task_counts"])
axes[1, 0].set_xlabel('Iteration')
axes[1, 0].set_ylabel('Tasks Processed')
axes[1, 0].set_title('Tasks Processed Over Time')
# Cumulative tasks
cumulative = [sum(self.metrics["task_counts"][:i+1])
for i in range(len(self.metrics["task_counts"]))]
axes[1, 1].plot(self.metrics["iteration_counts"], cumulative)
axes[1, 1].set_xlabel('Iteration')
axes[1, 1].set_ylabel('Cumulative Tasks')
axes[1, 1].set_title('Total Tasks Processed')
plt.tight_layout()
plt.savefig(output_path, dpi=300, bbox_inches='tight')
plt.close()
```
### Cost Optimization Strategies
Based on the Bridgewater research, here are strategies to keep costs down:
1. **Use smaller, domain-specific models** instead of large frontier models
- Your fine-tuned 7B model will be 13.8x cheaper than calling GPT-5.5
- Use larger models only for complex reasoning tasks
2. **Cache frequent queries**
- Store results for common patterns
- Use the knowledge graph to retrieve pre-computed answers
3. **Batch processing**
- Process multiple documents in a single batch
- Use interleaved batching for multi-task training
4. **On-policy distillation**
- Use the trained model as a teacher for future training
- Gradually improve without retraining from scratch
---
## Part 5: Connecting to Your Existing Blog
This implementation connects directly to the themes in your blog:
### Sovereign AI Architecture
Your **DeerFlow 2.0** work on sovereign AI agent systems with local-first architecture provides the foundation for this autoresearch system. The SuperAgent harness, AIO sandbox, and persistent memory are exactly what we need for the agent recipes and feedback loops.
### Dynamic Persona MoE RAG
Your **Dynamic Persona Mixture-of-Experts RAG** system is the perfect knowledge layer for the autoresearch loops. The dynamic personas can be specialized experts that evolve based on the feedback from the autoresearch cycle.
### Open Source Agent Development
Your guides on **Smolagents with Ollama**, **OpenAI Agents SDK integration**, and **building autonomous AI agents** provide the practical implementation patterns that we've integrated into this guide.
### Reinforcement Learning Foundations
Your **Complete Guide to Reinforcement Learning** provides the theoretical foundation for understanding GRPO, CISPO loss, and on-policy distillation that we're using in the fine-tuning pipeline.
### Knowledge Graph Architecture
Your work on **building private knowledge graphs** and **GraphRAG with Neo4j** is integrated into the sovereign AI system for structured reasoning and knowledge retrieval.
---
## Conclusion: The Future of Sovereign AI
We're at an inflection point. The frontier models we depend on are hitting diminishing returns on domain-specific tasks. But we have a better path:
1. **Build autoresearch loops** that continuously improve your AI system
2. **Create agent recipes** that encode human expertise in portable formats
3. **Fine-tune open-weight models** to outperform frontier models on your specific tasks
4. **Run everything locally** with complete data privacy
The result is a system that:
- Gets better over time without human intervention
- Costs a fraction of calling API services
- Maintains complete data sovereignty
- Develops expert-level judgment in your specific domain
This is the future of **differentiated intelligence**—AI systems that are specialized, self-improving, and completely under your control.
The tools are all open-source. The architecture is proven. The research backs it up. Now it's time to build.
---
## Additional Resources
- [Autoresearch: The feedback loop behind self-improving agents](https://www.latent.space/p/autoresearch-introspection) - Latent.Space
- [Learning to replicate expert judgment in financial tasks](https://thinkingmachines.ai/news/learning-to-replicate-expert-judgment-in-financial-tasks) - Thinking Machines Lab
- [DeerFlow 2.0: Building Sovereign AI Agent Systems with Local-First Architecture](https://thinkingmachines.ai/news/deerflow-2-building-sovereign-ai-agent-systems) - Your blog
- [Dynamic Persona MoE RAG: Building a Memory-Driven Synthetic Intelligence](https://yourblog.com/posts/dynamic-persona-moe-rag) - Your blog
- [Complete Guide to Reinforcement Learning: From MDPs to AGI](https://yourblog.com/posts/complete-guide-reinforcement-learning) - Your blog
- [Complete Ollama Smolagents Integration Tutorial](https://yourblog.com/posts/ollama-smolagents-integration) - Your blog
---
*This guide is part of a series on building sovereign AI systems. Stay tuned for more implementation details on fine-tuning strategies, production deployment, and advanced autoresearch patterns.*
---
**Key Takeaways:**
1. **The loop is the product** - Build systems that improve themselves through feedback loops
2. **Recipes encode expertise** - Create portable formats for human knowledge that agents can iterate on
3. **Fine-tuning beats prompting** - Domain-specific models trained on expert data outperform frontier models
4. **Local-first is sovereign** - Run everything locally with complete data privacy
5. **Start simple, iterate fast** - Begin with GRPO, then add interleaved batching and on-policy distillation
The future belongs to systems that learn from their failures, encode human expertise, and continuously improve. Build those systems, and you'll have AI that's truly sovereign.
---
canonical_url: /blog/2026-07-02-autoresearch-loops-and-differentiated-intelligence
categories:
- AI Architecture
- Agent Systems
date: 07-02-2026
description: 'A fact-checked, systems-level analysis of two converging ideas from AI Engineer World's Fair week: Introspection's "autoresearch" framework for self-improving agent loops, and Thinking Machines/Bridgewater AIA Labs' results on fine-tuning open-weight models to exceed frontier-model accuracy on expert judgment tasks.'
tags:
- autonomous-agents
- fine-tuning
- reinforcement-learning
- agent-recipes
- differentiated-intelligence
title: 'Autoresearch Loops and Differentiated Intelligence: Two Converging Blueprints for Self-Improving AI Systems'
sources:
- https://www.latent.space/p/autoresearch-introspection
- https://thinkingmachines.ai/news/learning-to-replicate-expert-judgment-in-financial-tasks
---
# Autoresearch Loops and Differentiated Intelligence
*A systems-level look at two ideas that surfaced the same week: why the "loop," not the model, is becoming the unit of product design, and why a well-trained 7–235B open-weight model can now beat frontier LLMs on tasks that require tacit expert judgment.*
## Why these two pieces belong together
Two things published within a day of each other in late June / early July 2026 describe the same underlying shift from different angles.
The first is an interview with Roland Gavrilescu, co-founder and CEO of Introspection, published on Latent.Space around his "Autoresearch in the Wild" talk at the AI Engineer World's Fair. Gavrilescu's argument is architectural: agent systems should be built as an inner loop that does the work and an outer loop — an "autoresearch" loop — that studies and improves the inner loop using signals, evals, and human input, without requiring a human in every decision.
The second is a research report from Thinking Machines Lab, produced in collaboration with Bridgewater AIA Labs. It's an empirical demonstration of *why* that architecture matters: on six realistic financial information-filtering tasks, frontier models plateaued below 80% accuracy no matter how well they were prompted, while a fine-tuned Qwen3-235B model trained on expert-labeled data reached 84.7% accuracy at roughly a fourteenth of the inference cost.
Read together, they sketch a coherent blueprint: general-purpose frontier models are a starting point, not an endpoint, for any task where the real difficulty is tacit judgment rather than reasoning or knowledge retrieval. The way you close that gap is by building a loop that captures expert judgment as data, and periodically distilling it into a smaller, owned, continuously improving model. This piece works through both sources in enough technical depth to be actionable, and is deliberately free of illustrative pseudo-code — the goal is the architecture and the evidence, not a toy implementation.
---
## Part 1: Autoresearch — the loop as the unit of product design
Gavrilescu's framing, as described in the interview, rests on three patterns he presented at AIEWF.
### Pattern 1 — The loop is the product
The industry's center of gravity has moved from models, to harnesses (the scaffolding around a model — tool use, memory, control flow), to loops. A loop in this sense is a system where an "outer" process continuously evaluates and improves an "inner" process. The hard engineering problem isn't building the loop — it's designing feedback signals precise enough that agents can absorb more responsibility over time without the system degrading into unreviewed, low-quality output ("slop," in Gavrilescu's word). This is a signal-design problem before it is a modeling problem: cheap, low-fidelity signals (thumbs up/down, raw error rates) tend to produce agents that optimize the metric rather than the underlying goal, while expensive, high-fidelity signals (expert review, structured evals) are the ones that actually transfer.
### Pattern 2 — Agent recipes
Gavrilescu proposes "recipes" as the artifact that a mature autoresearch loop produces and consumes. The analogy is to the data recipes used in model pretraining and post-training, which specify how much data from each domain should be blended into a training run. An agent recipe is the equivalent for an agentic system: it bundles the harness configuration, the evaluators and judges used to score outputs, the pieces of human expertise that have been captured, and — critically — the history of failures that produced each new eval. His illustration is useful: if you inherited Devin's codebase tomorrow, the code alone wouldn't tell you why the system looks the way it does. You'd want the failure history, not just the current state. A recipe is meant to be that portable, provider-agnostic record, so an agent's accumulated judgment doesn't live only inside a single deployment.
### Pattern 3 — Optimize for quality *and* cost together
The third pattern is about what the loop is allowed to optimize. Companies like Cursor and Cognition demonstrated that agent-native products can work at all; the next phase, in Gavrilescu's view, is making the same capability more accessible and cheaper — progressively distilling frontier-model capability into smaller systems an organization owns and tunes to its own environment. This is the direct architectural analogue of what the Thinking Machines/Bridgewater work demonstrates empirically in Part 2 below.
### Inner loop vs. outer loop
Mechanically, Gavrilescu separates two loops. The **inner loop** is the production system: the agent doing user-facing work. The **outer loop** is a separate system whose job is to study and maintain the inner loop — deciding what to improve, generating new evaluators, and deciding when a change is safe to promote. The open design question he flags is token-efficiency of the outer loop itself: an outer loop that spends unbounded compute deciding what to work on defeats the purpose.
### Humans are a tool inside the loop, not outside it
A point worth emphasizing because it cuts against a common assumption: Gavrilescu doesn't describe autoresearch as a path to removing humans. Instead, agents are trained to treat a human as callable resource — an "ask a human" tool — especially early in a loop's life, when the system has no accumulated preference data. As the loop accumulates examples of what a human would have done, it can act more autonomously, the same way a new employee asks more questions in their first weeks than after a year. Practically, this means the loop's early value comes from *how well it captures and structures those human answers*, not from how few questions it asks.
### Infrastructure and portability notes
Two implementation details from the interview are worth carrying into any local-first or sovereign-AI design:
- Gavrilescu describes the open-source **Pi** framework as "the Linux of agent harnesses" — a minimal, unopinionated agent loop that separates the core loop from extensions and configuration, so different agents can be assembled by loading different configuration into the same runtime, rather than forking the runtime itself. Introspection's product sits at the layer equivalent to a Linux distribution: managed infrastructure, cost controls, and security around that portable core.
- Work happens in Git, deliberately. Git becomes the audit log and the substrate recipes are built on top of, which keeps the system provider-agnostic and inspectable by both humans and future agents. This maps directly onto a design principle many local-first and audit-trail-conscious systems already favor: version-controlled, content-addressed history as the ground truth, rather than an opaque state store.
The strategic recommendation Gavrilescu gives engineers wanting to start is threefold: invest first in your feedback signals (most raw feedback isn't worth acting on — build a filter before you build a responder); put hard limits on cost per loop iteration before you scale it; and study how frontier labs construct data recipes, because the same discipline applies to recipes for agent behavior. The underlying reframe is to treat your own product organization as a small research lab, with agents functioning as junior researchers inside it.
---
## Part 2: The expert judgment problem — what the Bridgewater/Thinking Machines results actually show
This is where Pattern 3 above gets tested empirically, and it's worth being precise about the numbers, because the original figures floating around in secondhand summaries are frequently garbled.
### The task
Bridgewater AIA Labs and Thinking Machines Lab evaluated frontier models on six information-filtering tasks drawn directly from an investor's daily workflow: judging whether a financial article is relevant to a C-suite investor; determining whether a central bank document signals a future rate move; judging whether a research document answers a specific question; distinguishing boilerplate from unique analysis in recurring documents; and finding the exact point where boilerplate begins in a document or an email. None of these require novel reasoning — they require the same kind of fast, intuitive filtering an experienced investor does without being able to fully articulate the rule they're applying. The paper's own illustration is instructive: an article about a political figure claiming territorial ambitions over Greenland is *not* market-relevant, while an article about new tariffs triggering a market selloff clearly is — both are nominally "geopolitics," and the distinguishing judgment is hard to reduce to an explicit rule.
### Frontier models plateau around the mid-to-high 70s, not 50%
With a naive prompt that just states the task, frontier models — the report tested variants across Claude, Gemini, and GPT generations — averaged close to a coin flip, roughly 45–50% accuracy. That's not surprising for an under-specified prompt. The meaningful number is what happened *after* expert prompt engineering: investors rewrote the task instructions and, notably, found that reframing article classification from a binary label into three labels (relevant-and-interesting, relevant-but-uninteresting, irrelevant) improved model performance substantially. Even with this expert-tuned prompting, the best frontier model in the study — Claude Opus 4.8 — reached only 78.2% average accuracy, still short of the roughly 80% threshold the investors said they'd need to trust a system unsupervised in their daily workflow. The report also notes that accuracy gains across model generations were small relative to cost increases — GPT‑5.4 cost around 43% more per call than its predecessor for only a marginal accuracy gain, which is itself a useful data point against the assumption that "wait for the next frontier model" is a viable strategy for this class of problem.
### Why fine-tuning works where prompting stalls
The report's central diagnostic claim is that a prompt can only encode the portion of an expert's judgment the expert is able to articulate — and the judgments that matter most in tasks like this are exactly the ones experts find hardest to put into words. Fine-tuning sidesteps that articulation bottleneck: instead of forcing tacit judgment through the lossy channel of a written instruction, the training process lets a model infer the judgment directly from labeled examples of what the correct call was.
### Getting the training data right was the harder problem
Before any of the training techniques mattered, the team had to solve a data-quality problem. An initial dataset from non-expert labelers produced a poorly performing model — inspection of its reasoning traces showed the underlying labels were frequently wrong. Because expert labeling is expensive, the team built a verification scheme rather than expert-labeling everything from scratch: train a model on the non-expert-labeled data, run it against that same data, and route only the examples where the model disagreed with the label to an expert for adjudication. The logic is that disagreement on a training example usually means either the case is genuinely hard (informative) or the original label is wrong (noise to be corrected) — either way, that's where expert time is best spent. This is a reusable pattern independent of the financial domain: cheap-labeler-plus-selective-expert-review as a way to make expensive expert time scale across a large dataset.
### The training recipe, and what each component actually contributed
The base model was Qwen3-235B, trained using Thinking Machines' Tinker training infrastructure, chosen partly because its fine-tuning behavior is well studied in the open literature. It's worth being exact about the numbers here, since they're often mangled into a simple additive stack in secondhand retellings — the report presents them as **independent, leave-one-out ablations against a full final recipe**, not as sequentially compounding percentage gains:
- **Base model, no fine-tuning:** 44.8% average accuracy.
- **GRPO (critic-free RL) with standard importance-sampling loss:** jumped accuracy to 73.48% — the single largest gain in the whole recipe, and still short of the 80% target on its own.
- **Interleaved batching** (round-robin batches, one task at a time, rather than sequential per-task training or fully mixed batches): improved accuracy by 12.1 percentage points relative to the fully-mixed-batch baseline.
- **CISPO loss with asymmetric clipping**, replacing standard importance-sampling loss: improved accuracy by 10.1 percentage points over the importance-sampling baseline.
- **On-policy distillation (OPD) with a strong, periodically-promoted teacher:** the reward is shaped so the student is penalized for drifting too far from the teacher's output distribution; every 20 training steps the current checkpoint is promoted to teacher status, but only if it has set a new validation-accuracy high, so the model is never distilled toward a weaker version of itself. This produced a further 3.1 percentage-point gain over a frozen base-model teacher.
The final trained model reached **84.66% average accuracy and a 92.99% positive-class F1 score** — versus 78.2% for the best frontier model tested (Claude Opus 4.8) after expert prompt engineering. Framed as error reduction, that's roughly **29.8% fewer mistakes** than the best frontier model in the comparison. And because the deployed model is dramatically smaller than a frontier model, inference cost dropped by roughly **13.8x per task**.
### The limits of the claim, stated plainly
A few things are worth flagging so this doesn't get overstated. The result is domain- and task-specific: a fine-tuned Qwen3-235B beat frontier general-purpose models on six narrowly scoped filtering tasks where the "ground truth" was investor judgment, not an accuracy of exactly 84.7% at everything financial. The team explicitly says they've seen similar patterns on other internal tasks beyond the six published here, but that's a claim from the paper's authors about their own broader (non-public) task suite, not an independently verified general result. And the comparison is against a fixed set of frontier model snapshots (Opus 4.6, Opus 4.8, Gemini 3.1 Pro, GPT‑5.4, GPT‑5.5) as of roughly Q1–Q2 2026 — the point about diminishing returns per dollar across generations is real and worth taking seriously, but it's a snapshot, not a permanent law.
---
## Part 3: What this implies for building your own loop
Putting the two pieces together yields a fairly specific architectural recipe, stated at the level of principles rather than a specific stack, since the right concrete tools (local inference runtime, vector store, graph database, orchestration layer) will vary by environment and shouldn't be treated as fixed just because a particular open-source project happens to be popular this quarter.
**1. Separate the inner loop from the outer loop explicitly, as two different systems with two different SLAs.** The inner loop needs to be fast, reliable, and conservative. The outer loop is allowed to be slower and more exploratory, but needs its own budget — in tokens, dollars, and human review time — or it will silently become the more expensive half of the system.
**2. Treat "recipe" as a first-class artifact you version, not an implicit byproduct of your prompt history.** Concretely: your evaluators, your judges, the specific failure cases that motivated each one, and the provenance of every piece of captured human expertise should be stored together and be portable across models and providers — not baked into one harness's config format. This is the direct organizational analogue of a data recipe in pretraining.
**3. Don't assume prompting is a placeholder for fine-tuning — verify it empirically for your task.** The financial-filtering result is a clean illustration of a broader pattern: tasks that are fundamentally about tacit, hard-to-articulate judgment (as opposed to tasks that are fundamentally about knowledge access or multi-step reasoning) tend to show a real ceiling on prompt engineering, well below what a small fine-tuned model can reach on the same task with good data. The right diagnostic isn't "is this task hard" — it's "can an expert doing this task actually explain their rule out loud." If they can't, that's evidence for investing in a labeled dataset and fine-tuning rather than a longer system prompt.
**4. Solve the labeling bottleneck with selective expert review, not brute-force expert labeling.** The train-on-cheap-labels, verify-only-the-disagreements pattern is directly reusable outside finance: it's a general technique for making a small amount of true expert time cover a large training set, and it doubles as a debugging tool, since disagreement-driven review surfaces mislabeled data as a side effect.
**5. If you fine-tune, measure each technique's contribution independently rather than assuming gains stack additively.** The ablation table above is a useful template: report accuracy with each component removed from the final recipe, not a chain of "+X%, then +Y% on top of that," which overstates how techniques interact and makes the recipe harder to debug when one component stops helping on a new task.
**6. Keep the sovereignty argument honest.** The cost and ownership case for a smaller, fine-tuned, self-hosted model is genuinely strong here — 13.8x cheaper inference and higher accuracy than the frontier alternative is a real result, not a marketing claim. But it was earned through a nontrivial data-quality pipeline and a carefully tuned RL recipe, not by simply pointing an open-weight model at Ollama and calling it sovereign. The "local-first" and "differentiated intelligence" framings are compatible, but the second one requires you to actually build the labeling and evaluation infrastructure Part 2 describes — that infrastructure, not the choice of runtime, is where the accuracy and cost advantage actually comes from.
---
## Sources
- Richard MacManus, ["Autoresearch: The feedback loop behind self-improving agents,"](https://www.latent.space/p/autoresearch-introspection) Latent.Space, July 1, 2026 — interview with Roland Gavrilescu, co-founder and CEO of Introspection.
- Sarah Su, Kevin Zhu, Emily Xiao, Rohan Alur, Daniel Kang (Bridgewater AIA Labs), ["Learning to Replicate Expert Judgment in Financial Tasks,"](https://thinkingmachines.ai/news/learning-to-replicate-expert-judgment-in-financial-tasks) Thinking Machines Lab: News, June 30, 2026.
Got it — this is basically two overlapping drafts of the same piece plus a long implementation appendix. I’ve merged, cleaned, de-duplicated, and elevated it into a single coherent blog post with a consistent voice, tighter narrative flow, and corrected structure.
---
# Autoresearch Loops and Differentiated Intelligence
## Two Converging Blueprints for Self-Improving AI Systems
**Date:** July 2, 2026
**Categories:** AI Architecture, Agent Systems, Sovereign AI
**Tags:** autonomous-agents, fine-tuning, reinforcement-learning, agent-recipes, differentiated-intelligence, local-llms
---
## Introduction: The Shift from Models to Systems That Improve Themselves
Two major threads in AI research converged almost simultaneously.
On one side, Introspection’s “autoresearch” framework reframes AI systems not as static models, but as **self-improving loops**. On the other, Thinking Machines Lab and Bridgewater AIA Labs demonstrated something more concrete: **carefully trained open-weight models can outperform frontier LLMs on tasks requiring expert judgment—at lower cost and higher accuracy.**
Taken together, they point to a new design principle:
> The unit of intelligence is no longer the model. It is the loop.
This post synthesizes both perspectives into a single architecture for building **sovereign, self-improving AI systems**—systems that continuously refine their own behavior through evaluation, feedback, and fine-tuning.
---
## Part 1: Autoresearch — When the Loop Becomes the Product
Roland Gavrilescu’s framing at Introspection introduces a shift in how we think about agent systems.
### 1. The Loop Is the Product
Traditional AI systems are static:
> Train → Deploy → Maintain
Autoresearch systems are dynamic:
> Observe → Evaluate → Improve → Repeat
The key idea is that the **feedback loop itself becomes the product surface**.
But the hard problem isn’t building loops—it’s designing **signals that are meaningful enough for improvement without collapsing into noisy optimization**.
Cheap signals (likes, heuristics, weak metrics) lead to “slop optimization.”
Expensive signals (expert review, structured evals) are what actually move capability.
---
### 2. Agent Recipes: Capturing How Systems Evolve
A core concept is the **agent recipe**.
An agent recipe is not configuration—it is *history*:
- The model + harness configuration
- The evaluation suite used over time
- The human expertise embedded in the system
- The failure cases that led to new evaluations
- The decisions that shaped the system’s current behavior
If you inherited a production agent system, the code alone would not explain why it behaves the way it does. The recipe captures that missing context.
It is, effectively:
> A versioned memory of how intelligence was shaped.
---
### 3. Inner Loop vs Outer Loop
Autoresearch systems split into two interacting systems:
**Inner loop**
- Executes tasks
- Produces outputs
- Interfaces with users
**Outer loop**
- Observes performance
- Identifies failure patterns
- Creates new evaluations
- Updates prompts, tools, or training data
The outer loop is where improvement happens.
The inner loop is where value is delivered.
The key design challenge is ensuring the outer loop remains **cost-bounded and signal-efficient**, not a runaway optimization engine.
---
### 4. Humans as Tools in the Loop
A subtle but important shift:
Humans are not outside the system.
They are **callable components inside the loop**, especially early on.
As systems accumulate examples of human decisions, they reduce their reliance on explicit queries. This mirrors apprenticeship: early heavy supervision → gradual autonomy.
---
## Part 2: The Expert Judgment Problem
Autoresearch loops matter because of a deeper empirical limitation in current frontier models.
### Where Frontier Models Break
Bridgewater AIA Labs evaluated frontier models on six tasks involving real investment workflows:
- Financial article relevance
- Central bank document interpretation
- Boilerplate detection in research
- Email truncation detection
- Signal extraction from macroeconomic text
- General document relevance filtering
These are not reasoning-heavy tasks. They are **judgment-heavy tasks**.
And that distinction matters.
Even with strong prompting, frontier models plateaued around:
> ~78% accuracy
Below the threshold required for real-world deployment in expert workflows.
---
### The Core Limitation: Tacit Judgment
The key insight:
> Prompts can only encode what experts can articulate.
> The most important judgments are often non-verbalizable.
This is where prompting stops working.
---
### Why Fine-Tuning Wins
Fine-tuning bypasses articulation entirely.
Instead of translating intuition into instructions, it learns directly from examples of decisions.
The result:
- Base model: ~44% accuracy
- With GRPO + structured training: ~73%
- Final system: **~84.7% accuracy**
And critically:
- ~30% fewer errors than frontier models
- ~13.8× lower inference cost
This is not incremental improvement. It is a **regime shift in how capability is produced**.
---
### What Actually Mattered in Training
The gains did not come from a single trick. They came from structured system design:
- **GRPO-style RL**: largest jump in performance
- **Interleaved batching**: improves cross-task generalization
- **Loss function design (CISPO)**: stabilizes optimization
- **On-policy distillation**: prevents degradation over time
- **Carefully curated expert feedback loops**: highest leverage factor
But the most important bottleneck wasn’t architecture—it was **data quality and labeling strategy**.
A key technique:
> Train on cheap labels → route disagreements to experts → iterate
This turns expensive expert time into a targeted refinement signal rather than a brute-force labeling requirement.
---
## Part 3: What This Means — The New AI Architecture Stack
When you combine autoresearch loops with fine-tuning results, a consistent architecture emerges.
### 1. Separate Inner and Outer Loops Explicitly
- Inner loop: fast inference, stable behavior, user-facing reliability
- Outer loop: slow optimization, experimentation, evaluation-driven updates
They must be independently constrained.
---
### 2. Treat “Recipes” as First-Class Artifacts
Agent systems should not be defined by prompts or configs.
They should be defined by:
- Evaluation history
- Failure cases
- Data lineage
- Human correction traces
This is the difference between a system that works today and one that improves tomorrow.
---
### 3. Prompting Has a Ceiling
Prompt engineering works for:
- Knowledge retrieval
- Structured reasoning
- Clear rule-based tasks
It fails for:
- Tacit judgment
- Domain-specific intuition
- Expert-style filtering decisions
When the task depends on “feel,” you need data, not prompts.
---
### 4. Fine-Tuning Is Not Optional for Expert Systems
If a task meets this condition:
> “An expert cannot fully explain how they decide”
Then the correct solution is:
- Not better prompting
- Not longer context windows
- But supervised + RL fine-tuning pipelines
---
### 5. Cost Efficiency Comes from Specialization
The economic advantage is structural:
Smaller, specialized models:
- Beat frontier models on narrow expert tasks
- Cost an order of magnitude less
- Run locally with sovereignty guarantees
This is the foundation of **differentiated intelligence**.
---
## Part 4: Sovereign AI Systems — The Practical Architecture
The implementation pattern that emerges looks like this:
### Core Components
**1. Local inference layer**
- Ollama or similar runtime
- Open-weight models (Qwen, Llama, Mistral)
**2. Agent harness**
- Task execution layer
- Tool calling + orchestration
- Deterministic control flow
**3. Evaluation system**
- Domain-specific judges
- Failure detection logic
- Automated regression tests
**4. Outer loop system**
- Logs performance over time
- Generates new evaluations
- Updates recipes and datasets
**5. Fine-tuning pipeline**
- GRPO / RL-based optimization
- LoRA-based efficient training
- Distillation from stronger teachers
**6. Knowledge layer**
- Vector database (semantic memory)
- Knowledge graph (structured relationships)
- Persona routing (expert specialization)
---
## Part 5: The Key Insight — Intelligence Is Becoming Infrastructure
The convergence here is not accidental.
Both systems point to the same shift:
### Old paradigm
- Intelligence = model capability
### New paradigm
- Intelligence = system that improves itself
The model becomes just one component in a larger feedback architecture.
The real differentiator is:
- How you collect feedback
- How you structure evaluation
- How you convert experience into training signal
- How you close the loop
---
## Conclusion: From Models to Living Systems
The next generation of AI systems will not be defined by parameter count or context length.
They will be defined by:
- How quickly they learn from failure
- How well they encode expert judgment
- How tightly feedback loops are integrated into their architecture
- How cheaply they improve over time
Autoresearch provides the system design.
Fine-tuning research provides the empirical validation.
Together, they define a single direction:
> AI systems are becoming self-improving infrastructures for capturing and refining human expertise.
The model is no longer the product.
The loop is.
---
## Sources
- https://www.latent.space/p/autoresearch-introspection
- https://thinkingmachines.ai/news/learning-to-replicate-expert-judgment-in-financial-tasks
---
If you want, I can also:
- turn this into a **technical implementation series (Part 1–5 posts)**
- or compress it into a **landing-page style manifesto**
- or adapt it into your **“DeerFlow / sovereign AI architecture” canonical post style**
gpt-5-3-mini
now write an addendum with explanations using code examples
## Addendum: Implementation Notes and Minimal Code Examples for a Sovereign Autoresearch System
This addendum translates the architecture described above into concrete, minimal implementations. The goal is not production completeness, but to show how the pieces actually connect: inner loop, outer loop, evaluation layer, and fine-tuning pipeline.
---
# 1. Core Idea: Everything Reduces to a Loop
At runtime, every sovereign AI system collapses into the same structure:
```python
def run_system(task):
result = inner_loop(task)
score = evaluate(result)
feedback = outer_loop(task, result, score)
update_system(feedback)
return result
```
Everything else—agents, RAG, fine-tuning—is just implementation detail around this structure.
---
# 2. Inner Loop: Agent Execution Layer
The inner loop is the “worker.” It must be stable, deterministic enough to evaluate, and cheap enough to run repeatedly.
### Example: Local Agent with Ollama
```python
from ollama import chat
class InnerLoopAgent:
def __init__(self, model="qwen2.5:7b"):
self.model = model
def run(self, task, context=""):
prompt = f"""
You are an expert system.
Context:
{context}
Task:
{task}
Return a structured answer.
"""
response = chat(
model=self.model,
messages=[{"role": "user", "content": prompt}]
)
return response["message"]["content"]
```
### Key point:
The inner loop should NOT evolve itself. It only executes.
---
# 3. Evaluators: Turning Judgment into Code
Evaluators are where “taste” becomes computable.
### Example: Simple domain evaluator
```python
def relevance_evaluator(output: str, task: str) -> float:
"""
Scores whether output matches expected domain constraints.
In practice, this can be:
- heuristics
- small judge model
- embedding similarity
"""
keywords = ["market", "risk", "macro", "liquidity"]
score = sum(1 for k in keywords if k in output.lower())
return min(score / len(keywords), 1.0)
```
### Better version: LLM-as-judge
```python
def llm_judge(output, task, model="llama3.1:8b"):
prompt = f"""
Evaluate this output for correctness and relevance.
Task:
{task}
Output:
{output}
Score from 0 to 1 with explanation.
"""
res = chat(model=model, messages=[{"role": "user", "content": prompt}])
return parse_score(res["message"]["content"])
```
---
# 4. Outer Loop: Autoresearch Engine
The outer loop is the “researcher.” It looks at failures and modifies the system.
### Minimal implementation
```python
from collections import defaultdict
class OuterLoop:
def __init__(self):
self.failures = []
def record(self, task, output, score):
if score < 0.8:
self.failures.append((task, output, score))
def analyze_patterns(self):
patterns = defaultdict(int)
for task, output, score in self.failures:
if "market" in output:
patterns["market_bias"] += 1
if len(output) < 50:
patterns["verbosity_issue"] += 1
return patterns
```
---
# 5. Turning Failures into New Evaluators
This is the key autoresearch step: **the system writes its own tests.**
```python
def generate_new_evaluator(pattern_name):
if pattern_name == "verbosity_issue":
def evaluator(output, task):
return 1.0 if len(output) > 100 else 0.0
return evaluator
if pattern_name == "market_bias":
def evaluator(output, task):
banned = ["guaranteed profit", "risk-free"]
return 0.0 if any(b in output.lower() for b in banned) else 1.0
return evaluator
```
Then the outer loop injects this back into the system:
```python
class System:
def __init__(self):
self.evaluators = [relevance_evaluator]
def update(self, new_eval):
self.evaluators.append(new_eval)
```
---
# 6. Agent Recipe: The Versioned Intelligence Artifact
This is where system memory becomes structured.
```python
from dataclasses import dataclass, field
from datetime import datetime
@dataclass
class AgentRecipe:
name: str
model: str
evaluators: list
history: list = field(default_factory=list)
def log_failure(self, task, output, score):
self.history.append({
"task": task,
"output": output,
"score": score,
"time": datetime.now().isoformat()
})
def export(self):
return {
"name": self.name,
"model": self.model,
"evaluators": [e.__name__ for e in self.evaluators],
"history": self.history
}
```
### Key idea:
Recipes are not config files.
They are **compressed learning histories**.
---
# 7. Full Autoresearch Loop (Putting It Together)
```python
class AutoresearchSystem:
def __init__(self, agent, recipe):
self.agent = agent
self.recipe = recipe
self.outer = OuterLoop()
def step(self, task):
output = self.agent.run(task)
score = self.evaluate(output, task)
self.outer.record(task, output, score)
self.recipe.log_failure(task, output, score)
return output, score
def evaluate(self, output, task):
scores = [e(output, task) for e in self.recipe.evaluators]
return sum(scores) / len(scores)
def improve(self):
patterns = self.outer.analyze_patterns()
for pattern, count in patterns.items():
if count > 3:
new_eval = generate_new_evaluator(pattern)
self.recipe.evaluators.append(new_eval)
```
---
# 8. Fine-Tuning Hook: Closing the Loop with Learning
Once enough failures accumulate, we convert them into training data.
```python
def build_dataset(recipe):
dataset = []
for entry in recipe.history:
dataset.append({
"input": entry["task"],
"output": entry["output"],
"label": entry["score"]
})
return dataset
```
### Then fine-tune (LoRA-style sketch)
```python
from transformers import AutoModelForCausalLM
def fine_tune(model_name, dataset):
model = AutoModelForCausalLM.from_pretrained(model_name)
# pseudo-training loop
for batch in dataset:
loss = compute_loss(model, batch)
loss.backward()
return model
```
---
# 9. Knowledge Graph Hook (Optional but Powerful)
To move from “memory” to “structure”:
```python
import networkx as nx
class KnowledgeGraph:
def __init__(self):
self.graph = nx.DiGraph()
def add_fact(self, subject, relation, obj):
self.graph.add_edge(subject, obj, relation=relation)
def query(self, node):
return list(self.graph.neighbors(node))
```
### Example usage:
```python
kg = KnowledgeGraph()
kg.add_fact("inflation", "impacts", "interest_rates")
kg.add_fact("interest_rates", "impacts", "equities")
```
Now reasoning becomes graph traversal instead of pure generation.
---
# 10. The Complete System in One View
```python
agent → inner loop execution
↓
evaluation layer (judges)
↓
outer loop (failure analysis)
↓
recipe update (system memory)
↓
fine-tuning dataset generation
↓
model improvement
↓
back to agent
```
This is the full autoresearch cycle.
Not a metaphor.
A literal closed system.
---
# Closing Insight
Once implemented, something important becomes visible:
> Intelligence is no longer stored in the model.
It is distributed across:
- evaluation functions
- failure history
- training data generation
- update rules
- and loop structure itself
The model is just the *execution substrate*.
The loop is where intelligence actually accumulates.
---
If you want, next step I can:
- turn this into a **repo structure (folders + files + CLI tool)**
- or upgrade it into a **DeerFlow-compatible plugin system**
- or extend it with **multi-agent debate + RL optimization (GRPO-style loop)**
gpt-5-3-mini