DEV Community

massiron
massiron

Posted on • Originally published at massiron.com

Running a Local AI Engineering Agent with deepstrain: A Step-by-Step Tutorial

If you've ever wanted an AI agent that can read your codebase, run git commands, and execute bash scripts—all without sending a single byte to the cloud—deepstrain is worth a look. It's a local agent runner that connects to any OpenAI-compatible LLM (Ollama, LM Studio, GPT-4o, Claude) and gives you 52 built-in tools. The key difference from other agents: it plans first, then acts. You see the step-by-step reasoning before any tool runs.

Here's how to get it running in five minutes.

1. Install

pip install deepstrain
Enter fullscreen mode Exit fullscreen mode

That's it. No Docker, no API keys, no cloud setup. The package pulls in dependencies for file I/O, git, bash, web fetching, and code analysis via atlas.

2. Configure an LLM Backend

deepstrain needs an LLM behind it. If you have Ollama running locally with a model like codellama or deepseek-coder, create a config file:

# config.yaml
model:
  provider: ollama
  model_name: codellama:7b
  base_url: http://localhost:11434/v1
  temperature: 0.2
Enter fullscreen mode Exit fullscreen mode

For LM Studio, point to its local server:

model:
  provider: openai-compatible
  model_name: local-model
  base_url: http://localhost:1234/v1
  api_key: not-needed
Enter fullscreen mode Exit fullscreen mode

Or use a cloud API (still fully local execution, just the LLM call goes out):

model:
  provider: openai
  model_name: gpt-4o
  api_key: sk-...
Enter fullscreen mode Exit fullscreen mode

Save this as deepstrain.yml in your project root. If you skip it, deepstrain will prompt you interactively.

3. Run Your First Task

Let's ask it to summarize the git log of the current repo:

deepstrain "Show me a summary of the last 5 commits, grouped by author"
Enter fullscreen mode Exit fullscreen mode

Before any tool runs, you'll see the plan printed to stdout. Something like:

[Plan]
1. Run `git log --oneline -5` to get recent commits
2. Parse the output by author
3. Print grouped summary
Enter fullscreen mode Exit fullscreen mode

Then it executes step by step. Each tool call is logged with input, output, and duration.

4. See the Crash-Proof Logging

If a tool fails (e.g., network timeout on a web fetch), deepstrain doesn't crash silently. It writes a rotating log to ~/.deepstrain/logs/ with full context:

2025-03-20 14:32:01 | ERROR | web_fetch | https://example.com/api
  Tool: web_fetch
  Args: {"url": "https://example.com/api", "timeout": 10}
  Error: ConnectionError("Connection refused")
  Plan step: 2 of 5
Enter fullscreen mode Exit fullscreen mode

You get a friendly message in the terminal: "Web fetch failed. Retrying once..." If it fails again, the agent reports the error and asks if you want to continue.

5. Try a Real Refactoring Task with atlas

One of the 52 tools is code_analysis which uses atlas for deterministic code intelligence. Let's say you want to rename a function across a Python project:

deepstrain "Find all callers of function `parse_config` in src/ and rename it to `load_config`"
Enter fullscreen mode Exit fullscreen mode

The agent will:

  • Use code_analysis to build a call graph
  • List all files with references
  • Use file_read and file_write to make changes
  • Run git diff to show you the diff before applying

You approve each change interactively.

6. Activation and Pricing

deepstrain uses HMAC-SHA256 licensing with edge revocation. After install, you get a free trial. For Pro ($9/mo), you get unlimited tools, priority support, and offline activation. If you bring your own DeepSeek API key, each task costs about $0.009.

Activate with:

deepstrain --activate YOUR_LICENSE_KEY
Enter fullscreen mode Exit fullscreen mode

Once activated, it works fully offline—no phone-home required.

Why Not Just Use Ollama or LangChain?

  • Raw Ollama gives you a chat interface, not an agent with 52 tools and retry logic.
  • LangChain requires wiring up chains, memory, and error handling yourself.
  • deepstrain is pip install and a single command. Zero boilerplate.

Next Steps

Feedback welcome. If you hit an edge case, the logs will tell you exactly what happened.

Top comments (0)