DM-Code-Agent
A local-first, fully auditable Python coding agent whose runs you can replay, diff, fork and reproduce.
- Source repo
- hwfengcs/DM-Code-Agent
- Stars
- ★ 153
- Last updated
- 2mo ago
- FARS reviewed
- Oct 30, 2026
- License
- MIT
- Primary language
- Python
- FA score
- 54/100 · Major gaps
At a glance
- How it runs
- Works with
- Universal · cross-platformOpenAI API · Claude API
- Cost
- Free software; you pay for model usage
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- Researchers debugging agent behaviour who need to see which stage failed, whether a replan recovered it, and whether verification was skipped.
- Not a fit if
- Teams that must run untrusted code in an isolated sandbox
- Users who want a zero-setup hosted UI instead of a local install
- Chat-only workflows that never need to run tests or shell commands
- Maintenance
- Commits in the last 6 monthslast commit 2026-08-27
- Source review
- 54/100 · Major gaps
What does this agent do, and when should you use it?
DM-Code-Agent is a Python code agent that reads and writes files in your local workspace, runs tests and lint, and calls MCP tools, with a single ReAct loop at its core and everything else attached as lifecycle hooks. Every plan step, tool call and observation is written to an append-only JSONL session tree where each entry carries an id and parent_id; context folding appends a derived record instead of deleting the original text. The CLI ships dm-agent, dm-agent-eval, dm-agent-bench, dm-agent-trace, dm-agent-economics and dm-agent-manifest-diff, plus a dm-agent-web console that spawns a CLI subprocess so the browser and the terminal perform the same operation. Model clients for deepseek, openai, claude and gemini are built in, and custom providers can be registered. Evaluation is bundled: a 30-task hidden-test benchmark (15 coding, 15 maintenance) and a separate SWE-bench Verified subsystem measured with the official SWE-bench 4.1.0 harness (21/50 resolved, final error=0), with negative results published. Defaults follow a stated rule of guardrails on, behavioural algorithms off: read-before-edit, atomic writes with backup, observation truncation and token-budget folding are enabled, while Adaptive Replanning and similar modules require explicit flags.
Running dm-agent "<task>" --trace sessions/fix.jsonl --show-steps enters the ReAct loop: plan, parse the model response with response_parser, dispatch tools through tool_invoker, and pass a completion gate before delivery. The tool layer holds 17 built-in tools plus dynamically loaded MCP tools that read and write files, run tests and lint, and execute shell commands; a read-before-edit guard forces a read before any edit, and writes are atomic with automatic backup. Context folding runs locally and deterministically (Mem0-style atomic memory) and only commits when estimated_tokens_after < estimated_tokens_before, otherwise the candidate is rolled back together with memory, cadence and summary state. Afterwards dm-agent-trace view shows the timeline, analyze reports failure stage, replan recovery, verification gaps and a health score, diff compares two runs, fork --at <id> re-runs from any entry, replay re-executes tool calls, and analyze-dir aggregates a folder. dm-agent-bench runs the 30-task suite and dm-agent-score-diff reports per-task pass/fail flips rather than a single total. dm-agent-web exposes four audit views (session library, run detail, diagnostics, behaviour diff); --read-only needs no API key and can be statically hosted. Extensions are written as a module exporting setup(api) with register_tool, register_skill, register_provider and on, hooking before_tool_call, after_tool_result, before_llm_request, before_finish, on_run_start and on_run_end. Layer boundaries (clients → tools → tracing → core → extensions → cli) are enforced in CI by ruff TID251.
- Researchers debugging agent behaviour who need to see which stage failed, whether a replan recovered it, and whether verification was skipped.
- Engineers comparing two versions of a prompt or tool: dm-agent-trace diff shows the entry where the runs diverge.
- Teams adding a safety guard: drop in a Python file exporting setup(api) and block dangerous shell commands in before_tool_call without touching core code.
- Ablation work: behavioural modules are off by default, so you enable one flag at a time while the unfolded originals stay in the log for re-verification.
- Maintainers validating changes in CI with no network spend: pytest, deterministic evals and manifest checks run without an API key.
- Project leads who want a conversational workbench and an audit console in one place, including a read-only gallery that runs without a key.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Install / run
pip install -e ".[dev]"
- Config files
.env.example.envbench_reports/after.jsonbench_reports/before.json- Runtime
- Python 3.10+
How do you install or deploy this agent?
Requires Python 3.10+ and either uv or pip. Clone and install with dev extras:
bash
git clone https://github.com/hwfengcs/DM-Code-Agent.git && cd DM-Code-Agent
uv sync --frozen --extra devOr with pip:
bash
pip install -e ".[dev]"Create the environment file and fill in at least one model API key:
bash
cp .env.example .envVerify the install without spending anything — tests and deterministic evals need no key:
bash
python -m pytest && python -m dm_agent.evals.cli --variant full --task direct_finishHow do you use this agent?
Run a task and keep an auditable session log:
bash
dm-agent "fix the retry boundary in retry.py and run the tests" --trace sessions/fix.jsonl --show-stepsDiagnose that run immediately:
bash
dm-agent-trace analyze sessions/fix.jsonlReplay, compare, or fork from a specific entry:
bash
dm-agent-trace view sessions/fix.jsonl
dm-agent-trace diff a.jsonl b.jsonl
dm-agent-trace fork sessions/fix.jsonl --at 4f4bdeee-0007
dm-agent-trace replay sessions/fix.jsonlOpen the browser console (the terminal prints a tokenized URL):
bash
dm-agent-web --read-only # audit-only gallery, no API key needed
dm-agent-web # full workbench: multi-turn chat + SSE step streamScore the bundled benchmark and diff two reports:
bash
dm-agent-bench --suite all --provider deepseek --output bench_reports/after.json
dm-agent-score-diff bench_reports/before.json bench_reports/after.jsonSafety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
Makes outbound requests; verify telemetry settings and model data routing on private repos.
Inherits capabilities of connected MCP servers; audit third-party servers before enabling.
What are this agent's strengths and limitations?
- Context folding is guarded by a net-benefit check: it commits only when estimated_tokens_after < before, rolls back the whole candidate on a loss, and never deletes original entries.
- The session log is an id/parent_id entry tree with view, analyze, diff, fork, replay and analyze-dir commands, so any run can be re-executed from an arbitrary step.
- Extensions are concrete: register_tool, register_skill, register_provider and on, six interceptable hooks, five discovery tiers, and an explicit trust gate for project-local extensions.
- Audit output is machine-readable beyond a success flag: analyze surfaces verification_gap, edit_without_read, guard_blocks and truncations with a health score.
- Verification is broad and offline-capable: 554 passed / 1 skipped unit tests, 14 tasks × 4 variants of deterministic evals, vitest for frontend helpers, a 6-cell Ubuntu+Windows × Python 3.10/3.11/3.12 CI matrix, and layer contracts enforced by ruff TID251.
- Reporting is conservative: no unmeasured score claims, the non-working SWE-bench Lite subsystem was removed with the reason published, and the 20-task result is stated to be a strict prefix of the 50-task run.
- Real tasks require your own LLM API key and per-token spend; the software is free but no hosted quota is offered.
- Integration is CLI-shaped: the documented paths are the dm-agent commands and a spawned subprocess, with no stable library-level API for embedding ReactAgent.
- The published cross-repo SWE-bench Verified result (21/50) comes from one deepseek configuration and does not transfer to other providers without re-running.
- There is no Docker or sandbox layer; the agent reads, writes and executes shell in your own workspace, so protection depends on hooks you write yourself.
- The bundled benchmark is 30 tasks, so one flip is ±3.3 percentage points and the repeat-3 noise floor is roughly ±5 tasks — coarse for small deltas.
- v2.1 removed six default-off modules (Reflexion, Critic, Self-Consistency, breaker, memory hygiene, LLM compaction) and cut CLI flags from 35 to 23, so setups relying on them must migrate to external extensions.
How does this agent compare with similar options?
The README benchmarks the project against Aider, OpenHands, SWE-agent and smolagents. The concrete deltas it claims: session logs (JSONL entry tree with dry/tool replay, diff and fork, versus git diff in Aider, server log in OpenHands, trajectory in SWE-agent); an extension system with six interceptable lifecycle hooks (Aider and SWE-agent have no plugin path, OpenHands has plugins with partial hook coverage); non-destructive context folding where originals survive and can be recomputed offline (partial in OpenHands, weak in smolagents); a visual audit console (DM-Code-Agent and OpenHands ship full web UIs, Aider has a chat GUI); MCP integration (DM-Code-Agent and OpenHands yes, the others no); and a bundled hidden-test benchmark (only DM-Code-Agent offers a 30-task scored suite, while SWE-agent targets SWE-bench). Licensing: MIT here and for OpenHands and SWE-agent, Apache-2.0 for Aider and smolagents.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| DM-Code-Agent This agent | 54 · Major gaps | CLIFree + model costs | ★ 153 | 2mo ago | Python | OpenAI API · Claude API |
| Hello-Agents | 53 · Major gaps | Web appFree + model costs | ★ 88k | 10d ago | Python | OpenAI API |
| Beacon | 79 · Good | CLIFreemium | ★ 3.6k | today | Go | Codex · Claude Code |
| AgentLoom | 69 · Some gaps | — | ★ 168 | 10d ago | Python | OpenAI API |
How does FollowAgents rate this agent?
Why each dimension lost points
least_privilege: SECURITY.md explicitly states this is not a sandbox and can execute local files/Python/shell/MCP tools; permission boundaries rely on user isolation, so points deducted. user_confirmation: README mentions a before_tool_call hook can intercept dangerous operations and project-local extensions require explicit trust, but the default execution path shows no per-step confirmation, relying only on an optional hook, which is weak. data_flow_transparency: getting-started states the API key is read only from environment variables and not written to traces, and traces exclude full prompts and raw outputs by default, so transparency is good. sensitive_data_handling: there is a .env lookup order, BOM handling, and a conftest mechanism blocking real keys, but no details on mandatory redaction of sensitive content in traces, scored 2. dependency_security: dependencies have version upper bounds but openai/anthropic/google-genai have none, requirements.txt and pyproject are not fully consistent, and no vulnerability scanning or SBOM is present, points deducted. external_effects: the agent writes files, runs shell, and runs tests; despite atomic writes and backups, external side effects are broad and enabled by default, scored 1. rollback: atomic writes plus automatic backups, checkpoint/resume, fork re-runs, and collapse rollback are all described and test-supported, scored 2. source_attribution: README references devlog and bench_reports paths, but publisher identity is unverified and the author is only hwfengcs, so attribution evidence is limited.
self_consistency: README and pyproject version 2.0.0 agree, but README repeatedly says v2.1 while pyproject remains 2.0.0, a version inconsistency, points deducted. dependency_availability: pyproject and requirements.txt both list dependencies, web is an optional extra, and CI uses uv.lock --frozen, so availability is good; but the two dependency lists are not fully in sync. failure_messages: devlog 32 specifically fixed the missing-key error not including the path and improved the specific error message, with test coverage, scored 2.
audience_and_scenarios: aimed at developers; README and getting-started cover CLI, Web, benchmark, and extension scenarios, scored 2. capability_boundaries: SECURITY.md clearly states non-sandbox and only main branch support, and README notes the non-working SWE-bench Lite was removed, so boundaries are clear. trigger_precision: the CLI has seven entry points and many switches, but there is no precise description of trigger conditions, and the five-level extension discovery priority is described coarsely, scored 1. environment_fit: CI covers Ubuntu+Windows x 3.10/3.11/3.12 and handles Windows BOM, USERPROFILE, etc., so environment fit is good.
information_architecture: docs/ has navigation, six common documents, and 43 research-log entries, clearly structured. install_notes: getting-started gives pip/uv/venv installation methods and .env configuration in detail. naming_stability: seven console scripts have stable names, clearly defined in pyproject. examples_and_faq: there is examples/block_dangerous_shell.py and a known-pitfalls section, but the FAQ is not systematic. known_limitations: README explicitly avoids score inflation and lists removed modules and frozen evaluations, so limitations are transparent. license: the MIT LICENSE file is complete and the pyproject license field matches, scored 3. versioning_changelog: there is a research-log but no formal CHANGELOG, and the version number differs between README and pyproject, scored 1. maintenance_responsibility: the publisher is unverified, only main branch is supported, and maintenance responsibility is unclear, scored 1.
output_usability: trace view/analyze/diff/fork outputs are structured and benchmark output shows per-question flips, so usability is good. marginal_value: local-first plus auditable traces plus an extension system differentiate it from peers, but the core is still a ReAct loop, so marginal value is moderate. cost_benefit: an API key is needed to call the LLM, and the 30-question benchmark and 50-question SWE-bench are not cheap, with no cost quantification, scored 1.
claim_traceability: README claims such as 554 passed and SWE-bench 21/50 point to specific files and devlogs, so traceability is good, but static review cannot verify the numbers. cross_source_corroboration: README, devlog, and CI configuration corroborate some claims, but key numbers such as test counts have a single source, scored 1. fact_inference_separation: README clearly distinguishes measured from unmeasured and notes the 13-question baseline is not comparable to the 30-question one, so facts and inferences are well separated.
- SECURITY.md explicitly states this is not a sandbox and can execute shell and write files; use only in isolated workspaces, never on sensitive repositories.
- Publisher identity is unverified; review source and dependencies before installing the pip package.
- README repeatedly references v2.1 while pyproject version is 2.0.0, an inconsistency that undermines reproducibility claims.
- requirements.txt and pyproject.toml dependency lists diverge, and some SDKs lack upper bounds, risking dependency drift.
- Benchmark and SWE-bench scores are self-reported; static review cannot independently reproduce them, so do not rely on them alone for selection.
FAQ
How far can I get without an API key?
What can it actually touch on my machine?
Can I point it at my own model provider?
Does folding the context lose history, and where does the log live?
How do I tell whether a change improved anything?
Is DM-Code-Agent free?
Is DM-Code-Agent open source?
Is DM-Code-Agent safe to use?
Is DM-Code-Agent still maintained?
Who makes DM-Code-Agent?
Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.