Create single agents or robust multi-agent systems from plain English. One command plans, generates, quality‑checks, and packages a runnable agent; another runs a supervisor + workers loop.
- OpenAI GPT Models (via API key)
- Grok (via xAI API)
- Groq
- Ollama (local models like Llama3)
- Planning Agent: Analyzes requirements and creates detailed architecture plans
- Code Generation Agent: Generates production-ready Python code with best practices
- Testing Agent: Creates comprehensive test suites and suggests improvements
- Comprehensive Error Handling: Retry logic, timeout management, and graceful failure handling
- Configurable Settings: JSON-based configuration with environment variable overrides
- Detailed Logging: Full audit trail with configurable log levels
- Organized Output: Timestamped directories with generated code, tests, and documentation
- Input Validation: Thorough validation of inputs and API responses
- Type Safety: Full type hints and validation
If you just want to use it (no cloning needed):
pip install agentforgeXThen run (these console scripts are installed automatically):
agentforge plan --provider openai --use-case "Design a FAQ bot"
agentforge plan --provider groq --use-case "Design a FAQ bot"
agentforge generate --provider ollama --use-case "Summarize a CSV of sales"
agentforge multi --task "Explain caching layers" --provider groqNo API keys yet? Use --provider echo (deterministic mock) or set one of:
OPENAI_API_KEY, XAI_API_KEY, GROQ_API_KEY, ANTHROPIC_API_KEY.
To upgrade later:
pip install -U agentforgeXgit clone <repository-url>
cd AgentForge
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e '.[dev]'
# Single agent (plan + code + tests + packaging)
agentforge generate --provider openai --use-case "Summarize daily sales CSVs and flag anomalies"
# Multi-agent (offline deterministic)
agentforge multi --task "Explain caching layers" --provider echo --verbose
# Planning only
agentforge plan --provider ollama --use-case "Design an FAQ chatbot"Set environment variables for real providers:
export OPENAI_API_KEY="your-openai-api-key"export XAI_API_KEY="your-xai-api-key"Make sure Ollama is running locally:
ollama serveThe generate subcommand performs:
- Planning (LLM architecture plan with retries)
- Code generation + heuristic quality evaluation & refinement
- Test suggestions
- Deterministic fallback template if quality fails
- Packaging (requirements, run scripts, Dockerfile, README)
Artifacts land in generated_agents/<timestamp>/.
Legacy direct call (still works):
python src/main.py <provider> "<use case>"Start the FastAPI server (after installing new dependencies):
uvicorn src.api.app:app --reloadThen call endpoints:
curl -X POST http://127.0.0.1:8000/plan -H 'Content-Type: application/json' \
-d '{"provider":"openai","use_case":"Build an agent that summarizes emails"}'Full pipeline:
curl -X POST http://127.0.0.1:8000/pipeline -H 'Content-Type: application/json' \
-d '{"provider":"ollama","use_case":"Create an agent that tags support tickets"}'agentforge generate --provider grok --use-case "Analyze CSV data and output anomaly report"
agentforge generate --provider ollama --use-case "Customer support chatbot that escalates complex issues"
agentforge generate --provider openai --use-case "News summarizer that emails an AM briefing"Create or modify config.json to customize behavior:
{
"max_retries": 3,
"min_plan_length": 50,
"min_code_length": 100,
"output_base_dir": "generated_agents",
"create_timestamped_dirs": true,
"save_logs": true,
"log_level": "INFO",
"default_timeout": 120,
"default_temperature": 0.7,
"default_max_tokens": 4000,
"openai_model": "gpt-4o-mini",
"grok_model": "grok-beta",
"ollama_model": "llama3"
}Override configuration with environment variables:
export AGENTFORGE_MAX_RETRIES=5
export AGENTFORGE_LOG_LEVEL=DEBUG
export AGENTFORGE_OUTPUT_DIR=my_agents
export OPENAI_MODEL=gpt-4Each run creates a timestamped directory with:
generated_agents/
└── 20240822_143022/
├── README.md # Generation summary
├── agent_plan.txt # Detailed architecture plan
├── custom_agent.py # Generated agent code
└── test_agent.py # Test suite
main.py: Main orchestration logic with robust error handlingllm_providers.py: Multi-provider LLM interface with retry logic and proper response parsingconfig.py: Configuration management with file and environment variable support
- Input Validation: Validates provider and use case description
- Planning Phase: Creates detailed agent architecture with retry logic
- Code Generation: Produces clean, documented Python code
- Testing Phase: Generates comprehensive test suites
- Output Organization: Saves all artifacts with proper structure
- Retry Logic: Configurable retries for transient failures
- Timeout Management: Proper timeout handling for all API calls
- Graceful Degradation: Continues operation even if non-critical steps fail
- Detailed Logging: Comprehensive logging for debugging and monitoring
Configure different models per provider:
{
"openai_model": "gpt-4",
"grok_model": "grok-2",
"ollama_model": "llama3:8b"
}Control output behavior:
{
"create_timestamped_dirs": false, # Use single output directory
"output_base_dir": "my_custom_dir",
"save_logs": false # Disable log file creation
}Run a supervisor + worker loop:
agentforge multi --task "Draft phased migration plan" --provider openai
agentforge multi --task "Summarize caching strategy" --provider echo --verboseSupervisor must output NEXT:<agent> or FINISH:<answer>.
Workers output RESPOND:<answer> or TOOL:<name>:<arg>.
Add an extra worker (snippet):
from agents.base import BaseAgent
from agents.adapters import EchoLLM
from agents.orchestrator import Orchestrator
llm = EchoLLM()
sup = BaseAgent("supervisor", llm, "Supervisor: decide.")
worker = BaseAgent("worker", llm, "Worker: solve tasks.")
researcher = BaseAgent("researcher", llm, "Research facts.")
orch = Orchestrator({"worker": worker, "researcher": researcher}, sup, max_turns=8)Offline deterministic path (no keys): --provider echo.
- Core:
requestsfor HTTP API calls - Development:
pytest,black,flake8,mypy - Documentation:
mkdocs,mkdocs-material
- Fork the repository
- Create a feature branch
- Make your changes with proper tests
- Ensure code quality with
black,flake8, andmypy - Submit a pull request
MIT License - see LICENSE file for details.
API Key not found:
# Make sure environment variables are set
echo $OPENAI_API_KEY
echo $XAI_API_KEYOllama connection failed:
# Check if Ollama is running
curl http://localhost:11434/api/tagsGeneration timeout:
# Increase timeout in config.json
export AGENTFORGE_TIMEOUT=300Enable detailed logging:
export AGENTFORGE_LOG_LEVEL=DEBUG
python src/main.py <provider> "<use_case>"Check the log file for detailed error information:
See docs/USAGE.md for advanced multi-agent usage, tool authoring, roadmap, and a troubleshooting matrix.
tail -f agent_forge.log