# Confucius Code Agent

> Build AI code agents that scale to massive repositories with long-context reasoning and persistent memory. Confucius SDK achieves 59% Resolve@1 on SWE-Bench-Pro—ideal when AI needs to handle real-world codebases with complex toolchains.

- Skill: `adu2021/confucius-code-agent` (Agent Skill)
- Install (CLI): `npx skillmds@latest add adu2021/confucius-code-agent`
- Raw SKILL.md: https://api.skillmd.com/api/skills/adu2021/confucius-code-agent/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- License: MIT
- Author: adu2021 (https://skillmd.com/u/adu2021)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/adu2021/confucius-code-agent

---


## Overview

The Confucius SDK platform provides agent development infrastructure across three perspectives: Agent Experience (reasoning quality), User Experience (workflow naturalness), and Developer Experience (extensibility). Infrastructure enables long-context reasoning and persistent cross-session learning.

## When to Use

- Real-world software engineering tasks
- Large-scale repository modification
- Long-horizon code generation tasks
- Complex tool integration and coordination
- Need for agent persistence across sessions

## When NOT to Use

- Simple code snippets
- Single-file tasks
- Scenarios with simple tool requirements
- Real-time code patching

## Core Technique

Orchestrated agent with unified context management:

```python
# Confucius Code Agent
class ConfuciusCodeAgent:
    def __init__(self):
        self.sdk = ConfuciusSdk()
        self.long_context_manager = LongContextManager()
        self.note_memory = PersistentNoteMemory()
        self.tool_orchestrator = ToolOrchestrator()

    def solve_coding_task(self, task_description, repository):
        """Solve multi-file coding tasks at repository scale."""
        # Initialize agent with repository context
        self.long_context_manager.load_repository(repository)

        # Extract and compress repository information
        repo_summary = self.long_context_manager.summarize_repository()

        # Initialize persistent notes for this task
        session_notes = self.note_memory.create_session()

        # Hierarchical task decomposition
        subtasks = self.decompose_task(task_description)

        # Execute subtasks with context management
        for subtask_idx, subtask in enumerate(subtasks):
            # Update notes with progress
            self.note_memory.add_note(
                f"Executing subtask {subtask_idx}: {subtask}"
            )

            # Solve subtask with orchestrated tools
            result = self.solve_subtask(
                subtask,
                repo_summary,
                self.note_memory.get_relevant_notes(subtask)
            )

            # Record results in memory
            self.note_memory.add_note(f"Subtask {subtask_idx} result: {result}")

        # Iterate and refine
        for iteration in range(3):
            # Validate solution
            errors = self.validate_solution(repository)

            if not errors:
                break

            # Refine based on errors
            self.note_memory.add_note(f"Iteration {iteration} errors: {errors}")

            for error in errors:
                fix = self.fix_error(error, repository)
                self.note_memory.add_note(f"Applied fix: {fix}")

        return self.finalize_solution(repository)

    def unified_context_orchestrator(self, task, repository):
        """
        Manage context across long reasoning chains.
        Supports long-context reasoning on massive codebases.
        """
        # Estimate context requirement
        context_needed = self.estimate_context(task, repository)

        if context_needed > self.model.context_limit:
            # Compress repository information
            compressed = self.compress_repository_for_task(
                repository,
                task,
                max_tokens=self.model.context_limit - 2000
            )
        else:
            compressed = repository

        return compressed

    def solve_subtask(self, subtask, repo_summary, relevant_notes):
        """Solve single subtask with tool coordination."""
        # Tool orchestration: sequence of operations
        tools_to_use = self.plan_tools(subtask)

        result = None

        for tool in tools_to_use:
            if tool == 'grep':
                # Search repository for relevant code
                result = self.execute_grep(subtask)

            elif tool == 'edit':
                # Edit files based on analysis
                result = self.execute_edit(subtask, result)

            elif tool == 'test':
                # Run tests to validate changes
                result = self.execute_test(subtask)

            elif tool == 'compile':
                # Compile to check for errors
                result = self.execute_compile(subtask)

        return result

    def meta_agent_automation(self):
        """Meta-agent for iterative agent improvement."""
        # Build candidate agents
        candidates = self.generate_agent_candidates()

        # Evaluate on held-out tasks
        for candidate_agent in candidates:
            performance = self.evaluate_agent(candidate_agent)

            # Refine high-performing candidates
            if performance > threshold:
                refined = self.refine_agent(candidate_agent)

        return best_agent
```

## Key Results

- 59% Resolve@1 on SWE-Bench-Pro (surpasses research baselines)
- Long-horizon session persistence
- Scalable to massive repositories
- Reliable tool coordination

## References

- Original paper: https://arxiv.org/abs/2512.10398
- Focus: Real-world code agent scaffolding
- Domain: Software engineering, agent systems

