TL;DR
SolAgent is a specialized, tool-augmented multi-agent framework designed to generate secure and functionally correct Solidity smart contracts. By integrating a dual-loop refinement mechanism powered by the Forge compiler and Slither static analyzer, SolAgent achieves a remarkable Pass@1 rate of up to 64.39%, vastly outperforming vanilla LLMs and existing agent frameworks. Furthermore, the authors demonstrate that SolAgent's high-quality interaction trajectories can be distilled into smaller, open-source models, matching the performance of models four times their size.
What Problem Does This Paper Address?
Smart contracts are the backbone of decentralized applications (Web3), managing billions of dollars in digital assets. Because they are immutable once deployed on the blockchain, any bug or security flaw can result in catastrophic financial losses.
While Large Language Models (LLMs) excel at general code generation, they struggle with the rigorous demands of Solidity. They frequently suffer from "hallucinations" (like inventing non-existent libraries), fail to compile, or introduce subtle vulnerabilities like reentrancy. Existing multi-agent frameworks typically treat code generation as a pure text-processing task, lacking domain-specific verification tools and the file-system awareness required to resolve complex project dependencies.
Methods
SolAgent introduces a multi-agent architecture that mimics the workflow of human experts through three core modules:
- Multi-Agent Collaboration Framework: It divides labor between a Coding Agent (which analyzes requirements and writes the initial Solidity implementation) and a Refining Agent (which reviews feedback and directly modifies the code to fix bugs and optimize gas).
- Tool-Augmented Dual-Loop Refinement: Instead of a single-pass generation, SolAgent employs two distinct feedback loops:
- Inner Loop (Correctness): Uses the Forge compilation and testing framework to iteratively catch syntax errors and verify functional correctness against unit tests.
- Outer Loop (Security): Leverages the Slither static analyzer to detect and remediate security vulnerabilities.
- Additionally, the framework equips agents with File System Tools to explore project directories and read dependency files contextually, alongside a Dynamic Stopping Mechanism to prevent infinite loops or optimization stagnation.
- Workflow Distillation: To reduce the high computational cost of running multi-agent systems, the authors collect the successful interaction trajectories (both full-context and compressed-context summaries) and use them to fine-tune a lightweight, open-source model (Qwen3-8B).

Datasets
The paper evaluates its approach using the following datasets:
- SolEval+ Benchmark: A rigorous, file-level smart contract benchmark newly constructed by the authors. They extended the repository-aware, function-level SolEval dataset by aggregating 1,125 functions into 81 files and constructing 1,188 executable test cases using the Foundry framework.
- Fine-Tuning Trajectories (
dataset_trackeranddataset_mix): Dialogue histories collected from SolAgent runs on the SolEval+ training split, used to train the distilled models.

Key Insights and Ideas
- Solving the "Impossible Triangle": Single-pass code generation often forces a trade-off between functional correctness, security, and gas efficiency. SolAgent's dual-loop mechanism decouples these constraints, optimizing correctness first via compiler feedback, and then filtering for security via static analysis.
- Agent Trajectories as Distillation Goldmines: Multi-agent systems are notoriously token-heavy and expensive to deploy. However, treating their multi-turn reasoning trajectories as fine-tuning data allows researchers to "compress" multi-agent intelligence into a single-pass, lightweight model.
- Backward Truncation is Crucial: When training smaller models on long agent trajectories, retaining the end of the context (the final corrected code and successful execution) yields significantly better learning outcomes than keeping the beginning of the interaction.
Key Results
- Superior Functional Correctness: Paired with Claude-Sonnet-4.5, SolAgent achieved a 64.39% Pass@1 rate on SolEval+, compared to just ~25.59% for the vanilla LLM and 28.37% for the best agent baseline (Qwen-Agent).
- High Compilation Rates: SolAgent consistently achieved over a 90% compilation rate (up to 95.06%), whereas vanilla LLMs frequently hovered between 30% and 45%.
- Enhanced Security: SolAgent reduced security vulnerabilities by up to 39.77% compared to human-written baselines when utilizing GPT-5-Mini, and by 15.70% when using Claude.
- Effective Distillation: The distilled 8B model (
SolAgent-tracker-v2) quadrupled the Pass@1 rate of the base Qwen3-8B model and exactly matched the performance of the 4x larger Qwen3-32B model (1.31% Pass@1).
Limitations and Future Work
- Gas Optimization Trade-off: Because SolAgent's refinement process heavily prioritizes functional correctness and security, it occasionally generates code that consumes more gas than certain baseline models (such as GPT-5-Mini variants).
- Multi-Contract Complexity: The current framework focuses primarily on file-level generation. The authors note that future work will extend SolAgent to support more complex, multi-contract systems.
- Formal Verification: To provide even stronger security guarantees, the team plans to explore integrating formal verification tools directly into the agent feedback loop.
Summary updated