Skip to content

Repository files navigation

Coding Agent (DeepAgents Implementation)

A powerful multi-agent coding system built with deepagents, LangGraph, and the bmodel LLM wrapper. This agent can write, review, and refactor complex Python code autonomously while maintaining strict correctness and optimal time/space complexity.

Key Features

1. Virtual Sandbox (FilesystemBackend)

Instead of manually wiring up subprocess and filesystem tools, the implementation uses deepagents.backends.FilesystemBackend.

  • root_dir="sandbox": All file operations (reads, writes, lists) are automatically jailed to this directory.
  • virtual_mode=True: Ensures the backend operates securely within the confines of the sandbox, providing standard tools to the agent out-of-the-box.

2. State Persistence (Checkpoints)

The AsyncSqliteSaver from LangGraph is used to persist the agent's state.

  • By connecting to checkpoints.db, the agent can remember past interactions within a specific thread_id.
  • This is crucial for long-running tasks or multi-turn conversations where context needs to be preserved across sessions.

3. Multi-Agent Orchestration (SubAgents)

To prevent the main agent from being overwhelmed by complex tasks, work is delegated to specialized subagents. deepagents automatically exposes these subagents as tools to the main agent.

  • The Coding Agent (coding_agent): A dedicated worker for writing and modifying complex code. Offloads the heavy lifting of writing out files, allowing the main agent to focus on orchestration.
  • The Validator Agent (validator_agent): An elite code reviewer tasked with ensuring optimal time and space complexity. LLMs often take shortcuts (e.g., using O(n log n) .sort() for a Priority Queue insert instead of O(log n) heap operations). The validator acts as a strict gatekeeper to catch and reject sub-optimal code.

4. Advanced Prompt Orchestration

The true power of this setup comes from the strict, state-machine-like prompting used to orchestrate the subagents:

  • The validator is strictly mandated to output "STATUS: REJECTED" or "STATUS: APPROVED" and provide fixes for sub-optimal code.
  • The main orchestrator is instructed to run a rigid feedback loop: passing tasks to the coder, submitting the result to the validator, and returning feedback to the coder until it receives an APPROVED status. It is FORBIDDEN from finishing early.

Installation

Prerequisites

  • Python 3.13+
  • uv (for fast dependency management)

Setup

  1. Clone the repository and navigate to the project root:
    cd coding-agent
  2. Install dependencies using uv:
    uv sync
    (This will install langgraph, deepagents, aiosqlite, and my local bmodel package)

Usage

Run the main agent script:

uv run main.py

The script will automatically create the sandbox directory and begin generating and validating code (e.g., creating the optimal data structures). You can watch the files appear in real-time in the sandbox/ folder and inspect the SQLite database checkpoints.db for thread state.

About

Demoable Local Model Coding agent

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages