Forge is an open-source, lightweight agent framework for building AI agents with pluggable components. It provides a clean, modular architecture that makes it easy to create agents with different LLM providers and execution environments.
- 🔌 Pluggable Architecture: Interface-based design for maximum flexibility
- 🤖 LLM Provider Abstraction: Support for OpenAI-compatible APIs with extensibility for custom providers
- 🛠️ Tool System: Agent loop with tool execution and custom tool registration
- 🧠 Chain-of-Thought: Built-in thinking/reasoning capabilities for transparent agent behavior
- 💾 Memory Management: Conversation history and context management
- 🔄 Event-Driven: Real-time streaming of thinking, tool calls, and messages
- 🔁 Self-Healing Error Recovery: Automatic error recovery with circuit breaker pattern
- 🚀 Execution Plane Abstraction: Run agents in different environments (CLI, API, custom)
- 🤖 Headless Mode: Automated CI/CD workflows with git integration and PR creation
- 📚 Automated Documentation: AI-powered documentation updates on every PR
- 📦 Library-First Design: Import as a Go module in your own applications
- 🧪 Well-Tested: Comprehensive test coverage (196+ tests passing)
- 📖 Well-Documented: Clear, comprehensive documentation
go get github.com/entrhq/forgepackage main
import (
"context"
"log"
"os"
"github.com/entrhq/forge/pkg/agent"
"github.com/entrhq/forge/pkg/executor/tui"
"github.com/entrhq/forge/pkg/llm/openai"
"github.com/entrhq/forge/pkg/tools/coding"
)
func main() {
// Create LLM provider
provider, err := openai.NewProvider(
os.Getenv("OPENAI_API_KEY"),
openai.WithModel("gpt-4o"),
)
if err != nil {
log.Fatal(err)
}
// Create coding agent with built-in tools
ag := agent.NewDefaultAgent(provider,
agent.WithCustomInstructions("You are an expert coding assistant."),
)
// Register coding tools
coding.RegisterTools(ag, ".")
// Launch TUI executor
executor := tui.NewExecutor(ag)
if err := executor.Run(context.Background()); err != nil {
log.Fatal(err)
}
}- Syntax Highlighting: Full syntax highlighting for diffs and code blocks
- Diff Viewer: Interactive unified diff viewer with color-coded changes
- Command Palette: Quick access to settings, slash commands, and actions (Ctrl+P)
- Interactive Settings: Live configuration of auto-approval, model parameters, and system behavior
- Slash Commands: Built-in commands for common workflows (
/commit,/pr,/clear,/help) - Real-time Streaming: See agent thinking, tool calls, and responses as they happen
File Operations:
read_file- Read files with optional line rangeswrite_file- Create or overwrite files with automatic directory creationlist_files- List and filter files with glob patterns and recursive searchsearch_files- Regex search across files with context lines
Code Manipulation:
apply_diff- Surgical code edits with search/replace operationsexecute_command- Run shell commands with streaming output and timeout control
Agent Control:
task_completion- Mark tasks complete and present resultsask_question- Request clarifying information from usersconverse- Engage in natural conversation
- Workspace Guard: Prevent operations outside designated directories
- File Ignore System: Respect
.gitignoreand custom ignore patterns - Tool Approval: Review and approve tool executions before running
- Auto-Approval Whitelist: Configure safe operations to run automatically
- Command Timeout: Prevent runaway processes with configurable timeouts
- Token-Based Pruning: Automatic conversation history management
- Tool Call Summarization: Condense tool results to preserve context
- Composable Strategies: Mix and match context management approaches
- Threshold-Based Trimming: Keep conversation within model limits
- Automated Commits: Review and commit changes directly from the TUI
- Pull Request Creation: Generate PRs with AI-written descriptions
- Headless CI/CD: Run Forge in GitHub Actions and other CI/CD pipelines
- Automated PR Documentation: Auto-update docs when PRs are opened
- Change Tracking: Monitor file modifications across agent sessions
- Diff Preview: View changes before committing
- Installation - Setup and configuration
- Quick Start - Build your first agent
- Your First Agent - Detailed tutorial
- Understanding the Agent Loop - Core concepts
- Configure Provider - LLM provider setup
- Create Custom Tools - Extend agent capabilities
- Setup PR Documentation - Automated docs workflow
- Manage Memory - Context and history management
- Handle Errors - Error recovery patterns
- Test Tools - Testing strategies
- Optimize Performance - Performance tuning
- Deploy to Production - Production deployment
- Overview - System architecture
- Agent Loop - Agent execution model
- Tool System - Tool architecture
- Memory System - Memory management
- API Reference - Complete API docs
- Configuration - All config options
- Tool Schema - Tool definition format
- Message Format - Message structure
- Error Handling - Error types and recovery
- Performance - Performance characteristics
- Testing - Testing framework
- Glossary - Technical terms
See ADRs for detailed design decisions including:
- Automated PR Documentation
- Headless Git PR Creation
- Headless Git Integration
- XML Tool Call Format
- Auto-Approval System
- Context Management
- Streaming Commands
- TUI Design
Forge is built with a clean, modular architecture designed for extensibility:
pkg/
├── agent/ # Agent core, loop, prompts, memory
│ ├── context/ # Context management strategies
│ ├── git/ # Git integration
│ ├── memory/ # Conversation history
│ ├── prompts/ # Dynamic prompt assembly
│ ├── slash/ # Slash command system
│ └── tools/ # Tool interface and built-ins
├── executor/ # Execution environments
│ ├── cli/ # Command-line executor
│ └── tui/ # Terminal UI executor
├── llm/ # LLM provider abstraction
│ ├── openai/ # OpenAI implementation
│ ├── parser/ # Response parsing
│ └── tokenizer/ # Token counting
├── tools/ # Tool implementations
│ └── coding/ # File and command tools
├── config/ # Configuration management
├── security/ # Security features
│ └── workspace/ # Workspace isolation
└── types/ # Shared types and events
- Interface-First: Clean abstractions for maximum flexibility
- Event-Driven: Real-time streaming of agent activities
- Composable: Mix and match components as needed
- Testable: Comprehensive test coverage (200+ tests)
- Type-Safe: Strong typing with Go's type system
package main
import (
"context"
"log"
"os"
"github.com/entrhq/forge/pkg/agent"
"github.com/entrhq/forge/pkg/executor/cli"
"github.com/entrhq/forge/pkg/llm/openai"
"github.com/entrhq/forge/pkg/tools/coding"
)
func main() {
provider, _ := openai.NewProvider(os.Getenv("OPENAI_API_KEY"))
ag := agent.NewDefaultAgent(provider,
agent.WithCustomInstructions("You are a helpful coding assistant."),
agent.WithMaxIterations(50),
)
// Register all coding tools
coding.RegisterTools(ag, ".")
executor := cli.NewExecutor(ag)
executor.Run(context.Background())
}type WeatherTool struct{}
func (t *WeatherTool) Name() string { return "get_weather" }
func (t *WeatherTool) Description() string {
return "Get current weather for a location"
}
func (t *WeatherTool) Parameters() map[string]interface{} {
return map[string]interface{}{
"location": map[string]interface{}{
"type": "string",
"description": "City name",
"required": true,
},
}
}
func (t *WeatherTool) Execute(ctx context.Context, args map[string]interface{}) (string, error) {
location := args["location"].(string)
// Call weather API...
return fmt.Sprintf("Weather in %s: Sunny, 72°F", location), nil
}
// Register custom tool
ag.RegisterTool(&WeatherTool{})See examples/ for complete working examples.
- Go 1.21 or higher
- Make (optional, recommended)
- Git
# Clone repository
git clone https://github.com/entrhq/forge.git
cd forge
# Install development tools
make install-tools
# Run tests
make test
# Run linter
make lint
# Build CLI
make buildmake test- Run all tests with coveragemake lint- Run linters (golangci-lint)make fmt- Format codemake build- Build Forge CLImake install- Install Forge CLImake clean- Clean build artifactsmake all- Run all checks and build
# All tests
make test
# Specific package
go test ./pkg/agent/...
# With coverage
go test -cover ./...
# Verbose
go test -v ./pkg/tools/coding/We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- 🔌 Additional LLM provider implementations (Anthropic, Google, etc.)
- 🛠️ New tool implementations
- 📝 Documentation improvements
- 🐛 Bug fixes and performance improvements
- ✨ New features and enhancements
By participating, you agree to abide by our Code of Conduct.
For security issues, see our Security Policy.
- Core agent loop with tool execution
- OpenAI provider with streaming support
- Advanced TUI with syntax highlighting
- Complete coding toolkit (read, write, diff, search, execute)
- Context management with multiple strategies
- Auto-approval and settings system
- Git integration (commits and PRs)
- Headless mode for CI/CD automation
- Automated PR documentation workflow
- File ignore system for security
- Slash command system
- Self-healing error recovery
- XML/CDATA tool call format
- Comprehensive test suite (200+ tests)
- Additional LLM providers (Anthropic Claude, Google Gemini)
- Multi-agent coordination and handoffs
- Advanced executor implementations (HTTP API, Slack bot)
- Plugin system for third-party tools
- Enhanced memory with vector storage
- Web-based UI
- Agent marketplace and sharing
- Observability and monitoring
- Advanced debugging tools
- Multi-modal support (vision, audio)
See ROADMAP.md for detailed plans.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Built with ❤️ as part of the Entr Agent Platform.
- 📖 Documentation - Complete documentation
- 💻 Examples - Working code examples
- 🐛 Issues - Report bugs or request features
- 💬 Discussions - Ask questions and share ideas
- 📝 Changelog - Version history
- 🤝 Contributing - Contribution guidelines