Thanks to visit codestin.com
Credit goes to github.com

Skip to content

entrhq/forge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Forge

CI Go Report Card GoDoc License

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.

Features

  • πŸ”Œ 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)
  • πŸ“¦ Library-First Design: Import as a Go module in your own applications
  • πŸ§ͺ Well-Tested: Comprehensive test coverage (196+ tests passing)
  • πŸ“– Well-Documented: Clear documentation and examples

Installation

go get github.com/entrhq/forge

Quick Start

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"
)

func main() {
    // 1. Create an LLM provider
    provider, err := openai.NewProvider(
        os.Getenv("OPENAI_API_KEY"),
        openai.WithModel("gpt-4o"),
    )
    if err != nil {
        log.Fatal(err)
    }
    
    // 2. Create an agent with custom instructions
    ag := agent.NewDefaultAgent(provider,
        agent.WithCustomInstructions("You are a helpful AI assistant."),
    )
    
    // 3. Create a CLI executor
    executor := cli.NewExecutor(ag)
    
    // 4. Run the agent
    if err := executor.Run(context.Background()); err != nil {
        log.Fatal(err)
    }
}

Architecture

Forge is built with a clean, modular architecture:

  • Agent Core (pkg/agent): Agent loop, tools, prompts, and memory
  • LLM Providers (pkg/llm): Pluggable LLM provider implementations
  • Executors (pkg/executor): Different execution environments (CLI, API, etc.)
  • Types (pkg/types): Shared types, events, and interfaces

Key Components

  • Tools (pkg/agent/tools): Tool interface and built-in tools (task_completion, ask_question, converse)
  • Prompts (pkg/agent/prompts): Dynamic prompt assembly with tool schemas
  • Memory (pkg/agent/memory): Conversation history management
  • Stream Processing (pkg/agent/core): Real-time parsing of thinking, tools, and messages

See docs/architecture.md for detailed architecture documentation.

Project Structure

forge/
β”œβ”€β”€ pkg/              # Public, importable packages
β”‚   β”œβ”€β”€ agent/        # Agent core with loop, tools, prompts, memory
β”‚   β”‚   β”œβ”€β”€ tools/    # Tool system and built-in tools
β”‚   β”‚   β”œβ”€β”€ prompts/  # Prompt assembly and formatting
β”‚   β”‚   β”œβ”€β”€ memory/   # Conversation memory
β”‚   β”‚   └── core/     # Stream processing
β”‚   β”œβ”€β”€ llm/          # LLM provider abstractions
β”‚   β”‚   └── parser/   # Content parsers (thinking, tool calls)
β”‚   β”œβ”€β”€ executor/     # Execution plane abstractions
β”‚   β”‚   └── cli/      # CLI executor implementation
β”‚   └── types/        # Shared types and events
β”œβ”€β”€ internal/         # Private implementation
β”œβ”€β”€ examples/         # Example applications
β”‚   └── agent-chat/   # Complete agent example with custom tools
β”œβ”€β”€ docs/            # Documentation
└── .github/         # CI/CD workflows

Examples

Check out the examples/ directory for working examples:

  • Agent Chat (examples/agent-chat): Complete agent with tools, thinking, and custom tool registration

Running the Example

cd examples/agent-chat
export OPENAI_API_KEY="your-api-key"
go run main.go

The example demonstrates:

  • Agent loop with tool execution
  • Chain-of-thought reasoning (shown in brackets)
  • Custom tool registration (calculator)
  • Built-in tools (task_completion, ask_question, converse)
  • Multi-turn conversations with memory

Try asking:

  • "What is 15 * 23?"
  • "Calculate (100 + 50) / 3"
  • "What's 144 divided by 12, then add 5?"

Development

Prerequisites

  • Go 1.21 or higher
  • Make (optional, but recommended)

Setup

# Clone the 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

# Format code
make fmt

Available Make Targets

  • make test - Run tests with coverage
  • make lint - Run linters
  • make fmt - Format code
  • make examples - Build example applications
  • make run-example - Run simple example
  • make clean - Clean build artifacts
  • make all - Run all checks and build examples

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Code of Conduct

By participating in this project, you agree to maintain a respectful and inclusive environment.

Roadmap

  • Streaming response support
  • Basic CLI executor
  • OpenAI provider implementation
  • Tool/function calling system
  • Agent loop with infinite iterations
  • Chain-of-thought reasoning
  • Memory management and conversation history
  • Event-driven architecture
  • Custom tool registration
  • Self-healing error recovery with circuit breaker
  • Auto-pruning for memory management
  • Integration tests for full agent loop
  • Multi-agent coordination
  • Additional LLM provider implementations (Anthropic, Google, etc.)
  • Advanced executor implementations (HTTP API server, Slack bot, etc.)
  • Agent collaboration and handoffs

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

Built as part of the Entr Agent Platform.


Status: 🚧 Under Active Development

This framework is currently in early development. APIs may change as we iterate on the design.

About

Forge: Open-source, lightweight agent for executing anywhere

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •