Building Autonomous Agents with Devika
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:
- Plan the architecture
- Create the React components
- Implement data parsing
- Add visualizations
- Test the application
Core Concepts
Planning Engine
Devika's core capability is planning:
- Understand — Analyze the requirement
- Plan — Break down into actionable steps
- Execute — Implement each step autonomously
- Verify — Test and validate results
- 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:
- Search for relevant articles and documentation
- Analyze the results
- 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:
- Open the website in a browser
- Navigate to the login page
- Attempt to log in
- 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:
- How to install Devika using Docker or pip
- How to start a development task with Devika
- The core concepts: planning engine and autonomous execution
- Examples of building web apps and fixing bugs
- Advanced features: web research, browser automation, self-improvement
- Configuration options for custom and local LLMs
- Best practices for effective use
- 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.
