Confucius Code Agent: Scalable Agent Scaffolding for Real-World Codebases

Sherman Wong, Zhenting Qi, Zhaodong Wang, Nathan Hu, Samuel Lin, Jun Ge, Erwin Gao, Wenlin Chen, Yilun Du, Minlan Yu, Ying ZhangarXiv 2025 · DOI

Introduction

The Confucius Code Agent (CCA) and its associated Confucius SDK represent a significant advancement in AI-driven software engineering. By shifting the focus from raw large language model (LLM) scale to sophisticated "agent scaffolding," CCA achieves a record-breaking 59% Resolve@1 on SWE-Bench-Pro. This system demonstrates that the structural design of an agent—how it manages memory, context, and optimization—is as critical as the underlying model's reasoning capabilities.

Problem Statement: The Scalability Wall

Existing AI coding agents often struggle with real-world, enterprise-level repositories due to two primary challenges:

  1. Long-context Reasoning (C1): Agents frequently suffer from "context bloat," losing track of critical decisions or becoming overwhelmed by the sheer volume of interaction history in massive codebases.
  2. Long-term Memory (C2): Most agents operate in a vacuum, failing to retain knowledge across sessions or learn from previous failures, leading to redundant work and repeated errors.

System Architecture and Methodology

The Confucius SDK addresses these challenges through a modular system-level design that separates the core loop from its operational tools.

The Confucius SDK modular architecture separates the Orchestrator from Extensions and Environment, integrated with Long-term Memory.

Key components of the methodology include:

  • Modular Scaffolding: The system separates the Orchestrator (the reasoning loop) from Extensions (APIs, tools, and plug-ins), allowing for high modularity and easier debugging.
  • Context Management via Architect Agent: Rather than using naive truncation, an "Architect Agent" summarizes interaction histories into structured "Plans." This ensures the context window remains lean while preserving essential reasoning chains.
  • Note-taking and Hindsight: An asynchronous agent distills trajectories into Markdown notes, specifically recording "hindsight notes" for failures to prevent the agent from repeating mistakes in future sessions.
  • Meta-agent Optimization: A high-level agent automates the refinement of the worker agent by synthesizing configurations and tuning prompts based on observed performance failures.

Experimental Evaluation

CCA was evaluated across three rigorous benchmarks:

  1. SWE-Bench-Pro: 731 real-world tasks testing long-horizon problem-solving.
  2. SWE-Bench-Verified: 500 manually verified, solvable tasks.
  3. PyTorch-Bench: A custom benchmark of 8 complex issues from the PyTorch repository (Jan–Jul 2025) requiring deep domain expertise and specialized hardware (NVIDIA A100s).

Key Results

CCA set a new state-of-the-art (SOTA) performance standard, particularly when paired with advanced backbones like GPT-5.2.

Resolve Rate (%) on SWE-Bench-Pro, showing Confucius variants outperforming all baselines, reaching a peak of 59.0%.
  • SOTA Performance: CCA reached 59.0% Resolve@1 on SWE-Bench-Pro, exceeding all reported commercial and open-source results.
  • Scaffolding Efficiency: A key finding was that superior scaffolding can compensate for model scale; Claude 4.5 Sonnet with CCA (52.7%) outperformed Claude 4.5 Opus using standard proprietary scaffolding (52.0%).
  • Resource Optimization: The note-taking module reduced average token costs by 11k and interaction turns by 3 per task, proving that structured memory enhances both performance and compute efficiency.

Discussion and Insights

  • AX vs. UX: The researchers emphasize that Agent Experience (AX) should differ from User Experience (UX). While humans require verbose logs, agents perform better with compressed, structured state representations (e.g., XML-based tool calls).
  • Cross-Session Learning: By recording failure modes, the agent achieves a form of "learning" that persists across different problem-solving attempts, significantly reducing the cost of iteration.

Limitations and Future Work

Despite its success, CCA shows slight performance regressions when tasks require modifying a high number of files (10+), likely due to localization uncertainty. Future work will explore end-to-end Reinforcement Learning (RL) to allow the agent to learn optimal tool-use policies directly from environment feedback, potentially further increasing the "thinking budget" efficiency beyond the current 16k token plateau.

Summary updated

BibTeX
@misc{wong2025confucius,
  author = {Sherman Wong and Zhenting Qi and Zhaodong Wang and Nathan Hu and Samuel Lin and Jun Ge and Erwin Gao and Wenlin Chen and Yilun Du and Minlan Yu and Ying Zhang},
  title = {{Confucius Code Agent: Scalable Agent Scaffolding for Real-World Codebases}},
  year = {2025},
  eprint = {2512.10398},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.10398},
}
Figure