Skip to content

ReAct Agent Framework

Complete AI agent framework with MCP support, environments, reasoning strategies, objectives, memory, and built-in tools

Python 3.8+ License: MIT Version

Getting Started View on GitHub


What is ReAct?

ReAct (Reasoning + Acting) is a powerful agent pattern that combines:

  • 💭 Thought (Reasoning): Think about what to do next
  • Action (Acting): Execute actions using available tools
  • 👁️ Observation: Analyze the results and learn

This cycle continues until the agent has enough information to provide a complete answer.


✨ Key Features

  • Multi-Provider Support


    Support for OpenAI, Anthropic, Google Gemini, and Ollama

    agent = ReactAgent(provider="anthropic://claude-3-5-sonnet")
    
  • Built-in Tools


    Search, filesystem, computation, and more

    agent.use_tools("search.*", "filesystem.*")
    
  • Memory Systems (v0.10.0+)


    Chat + Knowledge memory separation for better performance

    agent = ReactAgent(
        chat_memory=SQLiteChatMemory("./chat.db"),
        knowledge_memory=ChromaKnowledgeMemory("./kb")
    )
    
  • Objectives System


    Goal-oriented agent management with tracking

    agent.objectives.add(Objective(goal="Complete task"))
    
  • Reasoning Strategies


    ReAct, ReWOO, Reflection, and Plan-Execute

    reasoning = ReActReasoning(agent, tools)
    
  • Environment Interaction


    Web, CLI, and filesystem environments

    env = WebEnvironment()
    env.step(Action("navigate", {"url": "..."}))
    
  • MCP Integration


    Connect to Model Context Protocol servers

    agent.add_mcp_server("npx", ["-y", "@mcp/server-filesystem"])
    
  • FastAPI-Style API


    Elegant and intuitive agent creation

    @agent.tool()
    def search(query: str) -> str:
        return results
    

🚀 Quick Start

Installation

pip install react-agent-framework

Your First Agent

from react_agent_framework import ReactAgent

# Create an agent
agent = ReactAgent(
    name="Assistant",
    description="A helpful AI assistant",
    provider="gpt-4o-mini"
)

# Add tools with decorators
@agent.tool()
def search(query: str) -> str:
    """Search the internet for information"""
    # Your search implementation
    return search_results

# Run the agent
answer = agent.run("What is the capital of France?")
print(answer)  # "The capital of France is Paris"

That's it! You've created your first ReAct agent. 🎉


💡 Why ReAct Agent Framework?

⚡ Simple and Powerful

Clean, FastAPI-inspired API that makes building agents a breeze:

agent = ReactAgent(name="Research Agent")

@agent.tool()
def search(query: str) -> str:
    """Search for information"""
    return results

answer = agent.run("Research quantum computing")

🔌 Plug and Play

Switch between AI providers with a single line:

agent = ReactAgent(provider="gpt-4o-mini")
agent = ReactAgent(provider="anthropic://claude-3-5-sonnet")
agent = ReactAgent(provider="google://gemini-1.5-flash")
agent = ReactAgent(provider="ollama://llama3.2")

📦 Batteries Included

Built-in tools for common tasks:

# Use all search tools
agent.use_tools("search.*")

# Use filesystem tools
agent.use_tools("filesystem.read", "filesystem.write")

# Use computation tools
agent.use_tools("computation.calculator")

# Or use everything
agent.use_tools("*")

🧠 Advanced Memory

Multiple memory backends for context retention:

from react_agent_framework.core.memory import ChromaMemory, FAISSMemory

# Vector-based memory with ChromaDB
agent = ReactAgent(memory=ChromaMemory(collection_name="my_agent"))

# Or FAISS for high-performance similarity search
agent = ReactAgent(memory=FAISSMemory(dimension=1536))

🎯 Goal-Oriented

Track and pursue objectives:

from react_agent_framework.core.objectives import Objective, Priority

agent.objectives.add(Objective(
    goal="Research climate change solutions",
    priority=Priority.HIGH,
    success_criteria=["Find 5 viable solutions", "Analyze feasibility"]
))

# Agent keeps objectives in mind while working
answer = agent.run("Help me with climate research")

💭 Multiple Reasoning Strategies

Choose how your agent thinks:

from react_agent_framework.core.reasoning import (
    ReActReasoning,      # Iterative thought-action-observation
    ReWOOReasoning,      # Plan all actions upfront
    ReflectionReasoning, # Self-critique and improve
    PlanExecuteReasoning # Adaptive planning
)

reasoning = ReActReasoning(agent, tools)
result = reasoning.reason("Complex problem to solve")

🖥 Environment Interaction

Agents can interact with different environments:

from react_agent_framework.core.environment import (
    WebEnvironment,   # Browser automation
    CLIEnvironment,   # Shell commands
    FileEnvironment   # File operations
)

# Web browsing
web_env = WebEnvironment()
web_env.step(Action("navigate", {"url": "https://example.com"}))

# Safe shell execution
cli_env = CLIEnvironment(safe_mode=True)
cli_env.step(Action("execute", {"command": "ls -la"}))

🔗 MCP Integration

Connect to external tool servers:

# Connect to filesystem MCP server
agent.add_mcp_server(
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
    name="filesystem"
)

# Connect to GitHub MCP server
agent.add_mcp_server(
    command="npx",
    args=["-y", "@modelcontextprotocol/server-github"],
    env={"GITHUB_TOKEN": "ghp_..."},
    name="github"
)

# All MCP tools are automatically available!

📚 Learn More

  • 5-Minute Quickstart


    Get up and running in minutes

    Quickstart

  • Feature Guides


    Deep dive into all features

    Features

  • API Reference


    Complete API documentation

    API

  • Examples


    Real-world usage examples

    Examples

  • LLMs.txt


    Complete documentation for LLM consumption (800+ lines)

    LLMs.txt


🤝 Community


📝 License

This project is licensed under the MIT License. See the LICENSE file for details.


Built with :heart: using ReAct Agent Framework

Get Started Now