Beyond Prompting: How SoL-Pi Scaled Auto-Research Loops to Discover a 45% More Token-Efficient Agent Harness
Slash LLM agent context costs by nearly 50% without degrading reasoning capability.
Large Language Model (LLM) agents tasked with complex software development, infrastructure management, and repository navigation often suffer from significant operational inefficiencies. The standard loop of inspecting directory trees, executing edits, reading outputs, running test suites, and planning next steps creates massive execution traces. Over a multi-turn trajectory, context usage explodes non-linearly, leading to runaway API usage costs and degraded reasoning performance.
While prompt optimization and manual agent engineering attempt to address these bottlenecks, they rarely discover underlying structural patterns in how agents interact with environments. SoL-Pi introduces a framework that applies recursive auto-research loops to search for, test, and validate runtime harness mechanisms across hundreds of environments.
Guided by principles inspired by Recursive Self-Improvement (RSI), the auto-research process discovered four complementary, high-impact mechanisms. Deployed together on the EdgeBench benchmark, SoL-Pi reduced total recorded token traffic by 44.7% to 49.0% and API costs by approximately one-third , while maintaining or improving baseline capability across models like GPT-5.6 Sol and Opus 5.
+---------------------------------------+
| Scaling Auto-Research Loop |
| - ~150 Proposed Directions |
| - ~500 Executable Environments |
| - 3,000+ Runs / 60,000+ Interactions |
+-------------------+-------------------+
|
v
+---------------------------------------+
| Four Retained Mechanisms |
+-------------------+-------------------+
|
+-------------------+----------------+-------------------+-------------------+
| | | |
v v v v
+---------------+ +-----------------------+ +------------------+ +-------------------------+
| Action Fusion | | Online Context Compact| | ObservationPack | | Evidence-Preserving |
| (Mutation + | | (Cost-Gated Plan-Step | | (Stable Handles | | Reducer |
| Execution) | | Compaction) | | & Excerpts) | | (Verified Log Receipts) |
+---------------+ +-----------------------+ +------------------+ +-------------------------+
The Engineering Paradigm: Auto-Research for Agent Runtime Harnesses
Rather than manually hand-crafting heuristics, SoL-Pi uses an AI optimizer operating inside a structured, automated research loop. The optimizer observes baseline execution traces, proposes candidate code or prompt changes, and validates these candidates in isolated, disposable environments.
Scale of Exploration
To discover robust patterns, the system executed:
- ~150 proposed hypothesis directions.
- ~500 executable research environments spanning web apps, CLI tools, machine learning pipelines, infrastructure scripts, and documentation repositories across C++, Java, Go, Rust, Python, and TypeScript.
- Over 3,000 discrete evaluation runs totaling more than 60,000 agent–environment interactions.
┌─────────────────────────────────────────────────────────────────────────────┐
│ RECURSIVE AUTO-RESEARCH FUNNEL │
└─────────────────────────────────────────────────────────────────────────────┘
[Trajectory Rollouts] ──► [Map-Reduce Analysis] ──► [Mechanism Proposal]
│
v
[Development Validation] ◄── [Independent Review] ◄── [Implementation]
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ GATE 1: Capability Filter │
│ (Must remain within pre-declared capability tolerance) │
└─────────────────────────────────────┬───────────────────────────────────────┘
│ PASS
v
┌─────────────────────────────────────────────────────────────────────────────┐
│ GATE 2: Efficiency Gate │
│ (Must improve at least one declared efficiency metric) │
└─────────────────────────────────────┬───────────────────────────────────────┘
│ PASS
v
┌─────────────────────────────────────────────────────────────────────────────┐
│ FREEZE CANDIDATE │
│ (Evaluated on Held-Out Environments without search feedback) │
└─────────────────────────────────────────────────────────────────────────────┘
Strict Isolation Principles
To ensure validity and prevent overfitting, the search protocol enforces strict boundaries:
- Unchanging Pre-declared Metrics: Capability requirements, efficiency metrics, and acceptable performance tolerances are fixed prior to search and isolated from the optimizing agent.
- Sequential Gating: A candidate must pass two sequential gates:
- Gate 1 (Capability): Every capability metric must remain within predefined tolerances.
- Gate 2 (Efficiency): The candidate must demonstrate a net positive reduction in at least one key efficiency metric (e.g., total token count, call frequency).
3. Strict Separation of Held-Out Data: Candidates are frozen before being run against held-out evaluation tasks. Results from held-out evaluations are never fed back into the search loop, eliminating validation-patching loops.
Deep Dive: The Four Discovered Mechanisms
The auto-research process yielded four key runtime mechanisms, each targeting a distinct phase of the agent execution lifecycle.
+-----------------------------------------------------------------------------+
| AGENT-ENVIRONMENT LIFECYCLE |
+-----------------------------------------------------------------------------+
1. Mutation & Execution Phase
└─► Mechanism: Action Fusion
└─ Context: Reduces round-trips by combining write and execute steps.
2. Raw Environment Output Phase
└─► Mechanism: Evidence-Preserving Reducer
└─ Context: Distills logs (>= 4 KB) using a secondary model; falls back on failure.
3. Context Retention Phase
└─► Mechanism: ObservationPack
└─ Context: Converts large outputs (>= 10 KB) into handles after two turns.
4. Long-Horizon Planning Boundary
└─► Mechanism: Online Context Compact
└─ Context: Compacts context dynamically based on cost-gated projections.
Mechanism A: Action Fusion
Problem
In standard agent architectures, modifying code and verifying the change requires distinct API turns: sending a file edit request, receiving a confirmation, issuing a command execution request (e.g., pytest), and receiving the test output. This multi-turn cycle introduces latency and increases context token volume.
Architectural Solution
Action Fusion extends file-mutation tools by integrating an optional follow-up command parameter directly into the tool schema (e.g., Edit/Write + then_run). The runtime harness executes the file modification and immediately triggers the execution command within the local workspace environment, returning both system states in a single payload back to the model.
Baseline Interaction (3 API Calls):
┌───────┐ 1. Edit File ┌─────────┐
│ ├────────────────►│ │
│ │ 2. File Saved │ │
│ │◄────────────────┤ │
│ │ 3. Run Tests │ Environment
│ Agent │────────────────►│ Harness
│ │ 4. Test Output │ │
│ │◄────────────────┤ │
│ │ 5. Analyze │ │
│ ├────────────────►│ │
└───────┘ └─────────┘
Action Fusion Interaction (2 API Calls):
┌───────┐ 1. Edit + then_run ┌─────────┐
│ ├────────────────────►│ Environment
│ Agent │ 2. File Saved + │ Harness
│ │ Command Output │ │
│ │◄────────────────────┤ │
└───────┘ └─────────┘
Analytical Breakdown
- Call Reduction: Collapses three distinct model-harness interactions into two.
- Lineage & Discovery: Discovered across a 27-iteration lineage. Initial prompt-only instructions yielded inconsistent command pairing; hard-coding explicit parameters into the harness tool schema stabilized execution and increased trigger success rates.
Mechanism B: Online Context Compact
Problem
Arbitrary compaction strategies (such as rolling context buffers or fixed-interval summaries) can trigger expensive summarization API calls at inappropriate moments, accidentally discarding critical state details or adding unnecessary overhead when remaining subtasks are short.
Architectural Solution
Online Context Compact evaluates compaction opportunistically at plan-step completion boundaries (tracked via the agent’s update_plan loop). The harness estimates the remaining number of model requests by evaluating the ratio of past requests per completed step against remaining unfinished steps.
[Subtask / Plan Step Completed]
│
v
Estimate Remaining Model Requests
(Based on past requests per step)
│
v
Calculate Projected Input Token Savings
│
v
+-----------------------------------------------+
| Pass Cost Gate Check? |
| Projected Savings > Prompt Cache Rewrite Cost |
+----------------───────┬───────────────────────+
│
+--------------+--------------+
│ │
[YES] [NO]
│ │
v v
Execute Context Compaction Maintain Full Context
Until Window Limits
Cost Gate Equation
Compaction is triggered if and only if the projected token savings exceed the prompt cache rewrite overhead, supplemented by a scaling cost factor:
The cost gate evaluates:
- Estimated input token savings over the remaining horizon.
- Cache-write vs. cache-read pricing ratios for the active model provider.
- Unrecovered rewrite costs from prior compactions (requiring higher savings margins for subsequent compaction steps).
If the cost gate passes or if usage approaches maximum context limits the system invokes native context compaction.
Mechanism C: ObservationPack
Problem
Large tool outputs such as full file reads, directory listings, or API responses frequently clutter context history. Even when the information becomes redundant in subsequent turns, its full text continues to consume context length with every API call.
Architectural Solution
ObservationPack establishes an adaptive local archiving strategy for all tool payloads exceeding 10 KiB :
Tool Output >= 10 KiB Generated
│
v
Archived locally in Harness Store
│
┌───────────────┴───────────────┐
│ │
Turn 1 & 2 Turn 3 Onward
└─► Transmitted in FULL └─► Replaced with:
to provider for • Unique Stable Handle
immediate reasoning. • Original Size Metadata
• Head/Tail Excerpt (1 KiB)
• On-Demand Page Retrieval Tag
By guaranteeing full context availability during the first two requests, the agent retains high-fidelity visibility during initial problem solving. On subsequent turns, replacing the raw payload with a lightweight pointer reduces token context while preserving access via pointer lookup.
Mechanism D: Evidence-Preserving Reducer
Problem
Build, compilation, and test suite logs often exceed 50 KiB, yet the vast majority of the payload consists of repetitive build step output. Passing raw logs directly into the primary model context wastes tokens, while unverified summaries risk hallucinating error codes or missing failed test names.
Architectural Solution
The Evidence-Preserving Reducer targets log outputs exceeding 4 KiB originating from specific build and test tool executions. Crucially, the reducer processes tool results before ObservationPack projects the model context. ObservationPack detects the reducer’s verified receipt marker and bypasses those outputs, ensuring verified evidence is preserved without secondary truncation.
[Raw Log Output (>= 4 KB)]
│
v
Low-Cost Model (GPT-5.6 Luna)
└─ Extracted Evidence Receipt
│
v
[Deterministic Verifier]
├── Schema Match Check
├── Source Content Hash Check
├── Exit Code Verification
├── Exact Failure String Quotation Check
└── Minimum Compression Ratio Check
│
┌───────┴───────┐
[PASS] [FAIL]
│ │
v v
Pass Compact Fallback to
Receipt to Unmodified Raw
Main Agent Original Output
Execution Pipeline
- Delegated Summarization: The harness diverts raw stdout/stderr to a low-cost secondary model (e.g., GPT-5.6 Luna).
- Deterministic Verification: Before passing the generated receipt to the main agent, a verifier validates five mandatory criteria:
- Correct JSON schema format.
- Valid source hash.
- Accurate exit status match.
- Verifiable, exact substrings for failure traces/quotes.
- Net size reduction achieved.
- Fail-Safe Fallback: If verification fails or sensitive environment details are flagged, the receipt is discarded, and the agent receives the original raw log.
Comparative Architecture & Experimental Benchmarks
The four mechanisms operate at distinct, complementary stages of the agent runtime loop:
EdgeBench Performance Results
Evaluated end-to-end on EdgeBench across multiple frontier model backends, SoL-Pi reduced token overhead while maintaining task success rates:
Token Traffic Reduction: [████████████████████░░░░░░░░░] 44.7% - 49.0% Reduction
API Cost Savings: [██████████████░░░░░░░░░░░░░] ~33.3% Cost Cut
Model Task Accuracy: [███████████████████████████] +5.3% to +12.8% Improvement
- Token Traffic Reduction: 44.7% to 49.0% overall recorded token reduction across multi-turn trajectories.
- Cost Reduction: Approximately one-third decrease in total API expenditure.
- Capability Score: Standalone mechanisms improved base task capability scores by 5.3% to 12.8% on EdgeBench, while boosting local token efficiency by 9.8% to 18.2% on targeted subtasks.
Implementation Reference for AI Engineers & System Architects
To integrate these mechanisms into custom agent frameworks (e.g., LangGraph, AutoGen, CrewAI, or custom harness loops), implement the following structural patterns:
Intercepting Execution Paths
+---------------------------+
| Agent Request Generator |
+-------------+-------------+
|
v
+---------------------------+
| Is Action Fusion Eligible?|
+------+-------------+------+
| |
[YES] [NO]
│ │
│ v
│ Execute Single Tool Call
v
+---------------------------+
| Execute Edit + Command |
+-------------+-------------+
|
v
+---------------------------+
| Raw Result Captured |
+-------------+-------------+
|
v
+---------------------------+
| Is Output >= 4 KB Log? |
+------+-------------+------+
| |
[YES] [NO]
│ │
v │
+─────────────────────────+|
| Evidence-Preserving ||
| Reducer ||
+────────────┬────────────+|
| |
v v
+---------------------------+
| Is Output >= 10 KB? |
| (Skip if Reducer Receipt) |
+------+-------------+------+
| |
[YES] [NO]
│ │
v v
+--------------+ +-----------+
| Apply | | Pass Raw |
| Observation | | Result |
| Pack | | |
+--------------+ +-----------+
│
v
+---------------------------+
| Subtask Completed Boundary|
+-------------+-------------+
|
v
+---------------------------+
| Evaluate Online Compact |
| Cost Gate |
+---------------------------+
Technical Considerations
- Order of Operations: The Evidence-Preserving Reducer should process raw tool output before ObservationPack evaluates payload thresholds. ObservationPack inspects the reduced receipt marker and bypasses secondary extraction if the log has already been compressed.
- Context Window Protection: Online Context Compact should function as both a cost-gated optimization step and an emergency context relief fallback when nearing token limits.
- Cross-Model Generalization: Combining targeted tool schema optimizations (Action Fusion) with context-pruning guardrails provides performance gains across different model families.
SoL-Pi: Recursively Scaling Auto-Research Loops for Efficient Agent Harness
Need High-Impact Technical Content for Your Engineering Team?
I partner with developer-tooling startups, SaaS platforms, and engineering teams to translate complex infrastructure, agentic systems, and backend architecture into publication-grade technical writing.
Whether you need deep-dive architecture essays, hands-on developer tutorials, or technical counter-narratives:
- 📩 Email: abhishekninja2018@gmail.com
- 💼 LinkedIn: linkedin.com/in/abhishekninja
- 🐦 X (Twitter): x.com/AvishekBanzzov
- 🛠️ Capabilities: Long-form Technical Essays | Hands-On Tutorials | Developer Tooling Deep-Dives | Technical Counter-Narratives


Top comments (0)