Building Autonomous Agents with Devika

DevikaAutonomousTutorialPlanning

Learn to build autonomous AI agents with Devika's planning engine, from basic setup to complex multi-step tasks.

Building Autonomous Agents with Devika

Introduction

Devika is an open-source AI software engineer platform that can autonomously plan and execute complex software development tasks. It combines high-level reasoning with code generation, testing, and deployment capabilities. In this tutorial, you'll learn how to use Devika to build autonomous agents.

Prerequisites

  • Docker installed
  • Python 3.10+
  • An LLM API key (OpenAI, Anthropic, or local model)

Installation

Using Docker (Recommended)

# Run Devika with Docker
docker run -d --name devika \
  -p 1337:1337 \
  -e LLM_API_KEY="your-api-key" \
  stitionai/devika

# Access the web interface
open http://localhost:1337

Using pip

pip install devika

# Run Devika
python -m devika

Quick Start

Step 1: Start Devika

docker run -d --name devika -p 1337:1337 stitionai/devika

Step 2: Open the Web Interface

Visit http://localhost:1337 in your browser.

Step 3: Enter Your Development Task

Build a React dashboard that displays sales data from a CSV file

Devika will:

  1. Plan the architecture
  2. Create the React components
  3. Implement data parsing
  4. Add visualizations
  5. Test the application

Core Concepts

Planning Engine

Devika's core capability is planning:

  1. Understand — Analyze the requirement
  2. Plan — Break down into actionable steps
  3. Execute — Implement each step autonomously
  4. Verify — Test and validate results
  5. Iterate — Improve based on feedback

Autonomous Execution

Devika can:

  • Write code in multiple languages
  • Run tests and fix failures
  • Search for information online
  • Interact with web applications
  • Deploy to cloud platforms

Example 1: Building a Web App

User: Build a React dashboard that displays sales data from a CSV file

Devika:
1. Plan the architecture
   - React frontend with chart components
   - CSV parser for data ingestion
   - Responsive dashboard layout

2. Create the React components
   - Dashboard layout
   - Chart components (bar, line, pie)
   - Data table

3. Implement data parsing
   - CSV to JSON conversion
   - Data transformation for charts

4. Add visualizations
   - Sales trends over time
   - Category breakdown
   - Geographic distribution

5. Test the application
   - Verify data accuracy
   - Test responsive design
   - Check performance

Example 2: Bug Fix

User: Fix the authentication bug in this Express API

Devika:
1. Analyze the codebase
   - Read authentication middleware
   - Check token validation logic
   - Review error handling

2. Identify the bug
   - Token expiration not being checked
   - Missing refresh token logic

3. Create a fix
   - Add token expiration check
   - Implement refresh token endpoint
   - Update error responses

4. Write tests
   - Test valid tokens
   - Test expired tokens
   - Test refresh flow

5. Verify the fix
   - Run test suite
   - Manual testing
   - Deploy to staging

Advanced Features

Web Research

Devika can search for information online:

"Research the latest best practices for React performance optimization in 2026"

Devika will:

  1. Search for relevant articles and documentation
  2. Analyze the results
  3. Incorporate findings into the implementation

Browser Automation

Devika can interact with web applications:

"Test the login flow on https://example.com and report any issues"

Devika will:

  1. Open the website in a browser
  2. Navigate to the login page
  3. Attempt to log in
  4. Report any errors or issues

Self-Improvement

Devika learns from feedback:

User: The code you generated has a bug - the API returns 401

Devika:
1. Analyze the error
2. Review the authentication code
3. Identify the issue (missing Authorization header)
4. Fix the code
5. Re-test to verify the fix

Configuration

Using Custom LLMs

# Environment variables for custom LLM
export LLM_API_KEY="your-api-key"
export LLM_BASE_URL="https://api.your-llm.com/v1"
export LLM_MODEL="your-model-name"

Using Local Models

# With Ollama
export LLM_API_KEY="ollama"
export LLM_BASE_URL="http://localhost:11434/v1"
export LLM_MODEL="llama3"

Best Practices

1. Be Specific in Your Requests

# Good
"Create a REST API with Flask that has GET /items, POST /items, and GET /items/:id endpoints"

# Less effective
"Make an API"

2. Break Down Complex Tasks

# Better to break down:
1. "Create a Flask app with basic routing"
2. "Add a /items endpoint that returns a list"
3. "Add a /items/:id endpoint for single items"
4. "Add POST /items for creating items"
5. "Add database storage for items"

3. Review Generated Code

Devika is powerful but not perfect. Always:

  • Review generated code before using in production
  • Run tests to verify functionality
  • Check for security issues

4. Use Iterative Refinement

User: Build a login system

Devika: [generates code]

User: Add password hashing and JWT tokens

Devika: [updates code]

User: Add rate limiting and input validation

Devika: [further improves code]

Troubleshooting

Docker Container Not Starting

# Check logs
docker logs devika

# Restart container
docker restart devika

LLM API Errors

# Verify API key
curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $LLM_API_KEY"

# Check rate limits
# Some models have rate limits that may cause failures

Slow Performance

# Use a faster model for initial development
export LLM_MODEL="gpt-4o-mini"

# Use a more capable model for complex tasks
export LLM_MODEL="gpt-4o"

Resources

Summary

In this tutorial, you learned:

  1. How to install Devika using Docker or pip
  2. How to start a development task with Devika
  3. The core concepts: planning engine and autonomous execution
  4. Examples of building web apps and fixing bugs
  5. Advanced features: web research, browser automation, self-improvement
  6. Configuration options for custom and local LLMs
  7. Best practices for effective use
  8. Troubleshooting common issues

Devika provides a powerful, open-source AI software engineer with strong planning capabilities and web research integration. Start with simple tasks and gradually work up to more complex projects as you learn the system's capabilities.