coding by Promptsicle Team

Claude Agent System Recreated as Open Framework

Developers recreate Anthropic's Claude agent system as an open-source framework, enabling AI agents to use tools and execute complex tasks independently.

Claude’s Agent System Reverse-Engineered as Open Framework

A developer has successfully reverse-engineered Anthropic’s Claude agent system and released it as an open-source framework called “Agentarium.” The project, published on GitHub last week, recreates the core architecture that powers Claude’s ability to use tools, maintain context, and execute multi-step tasks without requiring API access to Anthropic’s proprietary systems.

First Impressions

Agentarium strips away the commercial packaging of Claude’s agent capabilities and exposes the underlying patterns. The framework runs on any LLM that supports function calling, including local models like Llama 3 and Mistral. Initial tests show it can replicate roughly 70-80% of Claude’s agent behaviors when paired with GPT-4 or Claude itself through standard API calls.

The repository includes three core components: a state manager that tracks conversation context and tool usage, a planning module that breaks complex requests into subtasks, and an execution engine that handles tool calls and error recovery. Documentation reveals that the developer analyzed thousands of Claude API responses to identify consistent patterns in how the model structures agent workflows.

What stands out is the simplicity of the implementation. The entire framework consists of under 2,000 lines of Python code, suggesting that effective agent systems rely more on orchestration patterns than complex algorithms. The state manager uses a directed acyclic graph to track dependencies between subtasks, preventing circular reasoning loops that plague many agent implementations.

Core Features

The framework implements tool registration through decorators, allowing developers to expose any Python function as an agent-callable tool. Here’s a basic example:

from agentarium import Agent, tool

@tool(description="Searches documentation for relevant information")
def search_docs(query: str, max_results: int = 5) -> list:
    # Implementation here
    return results

agent = Agent(model="gpt-4", tools=[search_docs])
response = agent.run("Find information about API rate limits")

The planning module breaks down requests using a technique the developer calls “recursive task decomposition.” When an agent receives a complex query, it generates a tree of subtasks, estimates which tools each subtask requires, and executes them in dependency order. Failed subtasks trigger automatic retries with modified parameters or alternative approaches.

Error recovery mechanisms include automatic context pruning when token limits approach, fallback strategies when tools return unexpected results, and a “reflection” phase where the agent evaluates whether its actions achieved the intended goal. This reflection step, apparently inspired by patterns observed in Claude’s responses, significantly improves success rates on multi-step tasks.

The framework also implements memory management that mimics Claude’s approach to long conversations. It maintains a rolling window of recent exchanges while summarizing older context into compressed representations. This allows agents to reference information from early in a conversation without exhausting context windows.

Workflow Integration

Agentarium integrates with existing Python codebases through a plugin architecture. Developers can add custom tool categories, modify the planning algorithm, or inject custom logic into the execution loop. The framework exposes hooks at each stage of the agent lifecycle, from initial query parsing through final response generation.

The project includes adapters for common development workflows. A Jupyter notebook extension allows researchers to run agent tasks inline with data analysis code. A CLI tool enables shell integration, letting agents interact with file systems and execute terminal commands. Web framework adapters for FastAPI and Flask allow agents to handle HTTP requests directly.

Performance benchmarks show the framework handles typical agent tasks with 30-40% fewer API calls than naive implementations that don’t optimize tool usage. The planning module’s ability to parallelize independent subtasks reduces end-to-end latency by similar margins. Local model support means developers can prototype agent behaviors without incurring API costs, though capabilities drop noticeably compared to frontier models.

Verdict

Agentarium demonstrates that sophisticated agent behaviors don’t require proprietary systems or specialized infrastructure. The framework’s clean architecture makes it valuable both as a production tool and as educational material for understanding agent design patterns.

The project’s main limitation is its dependence on underlying model quality. Weaker models struggle with the planning phase, often generating subtask trees that don’t align with available tools. The framework can’t compensate for models that hallucinate tool parameters or misinterpret results.

For developers building agent systems, Agentarium offers a battle-tested starting point that encodes lessons from one of the industry’s most capable agent implementations. The code is available at https://github.com/agentarium/agentarium under an MIT license, with active development continuing as contributors identify additional patterns worth replicating.