Skip to main content

ReActFlow

A lightweight, observable ReAct Agent framework

中文文档 | English

Features • Installation • Quick Start • Documentation • Contributing


Features

  • 🚀 5-minute setup - Get started with minimal code
  • 🔍 Fully observable - Track every thought, action, and observation
  • 💰 Cost transparent - Real-time token usage and cost tracking
  • 🛠 Easy customization - Define tools with simple decorators
  • 🔄 Loop detection - Automatic detection of stuck agents
  • 📦 Zero dependencies core - Minimal dependencies for maximum flexibility

Installation

pip install reactflow

Quick Start

Basic Usage

from reactflow import Agent, Tool

# Define a custom tool
@Tool.define
def search(query: str) -> str:
    """Search for information"""
    return f"Results for: {query}"

# Create an agent
agent = Agent(tools=[search])

# Run a task
result = agent.run("What is the capital of France?")
print(result.answer)

CLI Usage

# Run a single task
reactflow run "Calculate 25 * 17"

# Start interactive mode
reactflow interactive

# Export trajectory
reactflow run "What is Python?" --export trajectory.json

Built-in Tools

ReActFlow comes with several built-in tools:

Tool Description
search Search for information
calculator Evaluate mathematical expressions
datetime Get current date and time
text_analyzer Analyze text in various ways

Custom Tools

Create custom tools easily:

from reactflow import Tool

@Tool.define
def my_tool(query: str, count: int = 5) -> str:
    """
    My custom tool description.

    Args:
        query: The search query
        count: Number of results

    Returns:
        The result string
    """
    return f"Found {count} results for '{query}'"

# Use it
agent = Agent(tools=[my_tool])

Tracking Execution

Every execution generates a complete trajectory:

result = agent.run("What is 2+2?")

# Get the trajectory
trajectory = agent.get_trajectory()

# Export as Markdown
trajectory.export("my_trajectory.md", format="markdown")

# Or as JSON
trajectory.export("my_trajectory.json", format="json")

Configuration

agent = Agent(
    tools=[search, calculator],
    model="gpt-4",           # LLM model
    max_steps=10,            # Maximum reasoning steps
    debug=True,              # Enable debug output
    temperature=0.7,         # LLM temperature
)

Architecture

ReActFlow Architecture
│
├── Agent              # Main interface
│   ├── Engine         # ReAct execution loop
│   ├── Tools          # Tool registry and execution
│   ├── State          # Execution state tracking
│   └── Memory         # Conversation memory
│
└── CLI                # Command-line interface

Why ReActFlow?

ReActFlow Other Frameworks
5 lines to start 20+ lines of setup
Full observability Black box execution
Debug-friendly Hard to trace issues
Cost transparent Unknown token usage
Minimal dependencies Heavy dependency chains

Academic Reference

This framework implements the ReAct (Reasoning + Acting) paradigm from the following paper:

ReAct: Synergizing Reasoning and Acting in Language Models

Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R. Narasimhan, Yuan Cao

ICLR 2023

Paper: https://arxiv.org/abs/2210.03629

@inproceedings{yao2023react,
  title={ReAct: Synergizing Reasoning and Acting in Language Models},
  author={Yao, Shunyu and Zhao, Jeffrey and Yu, Dian and Du, Nan and Shafran, Izhak and Narasimhan, Karthik R and Cao, Yuan},
  booktitle={International Conference on Learning Representations (ICLR)},
  year={2023}
}

License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2024 AI Agent Research Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

Contributing

We welcome contributions! Please see our Contributing Guide for details.


Made with ❤️ by AI Agent Research Team

Metadata

Release files for reactflow 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reactflow 0.1.0
File Size Uploaded Provenance Actions
reactflow-0.1.0.tar.gz 22.1 kB Without provenance Details for reactflow-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for reactflow 0.1.0
File Interpreter ABI Platform Actions
reactflow-0.1.0-py3-none-any.whl Python 3 none any Details for reactflow-0.1.0-py3-none-any.whl

Total release size: 43.9 kB

Release files / reactflow-0.1.0.tar.gz

Download URL reactflow-0.1.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e914bc3dfa935811c4f9df0ef09e4636182443cb3bd546cd1a68be45486c7cd6
BLAKE2b-256 checksum
How to use checksums
5690b5c333170a470b148387a9390072c2d8c35107a60b59e274ee51ab2d0932
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / reactflow-0.1.0-py3-none-any.whl

Download URL reactflow-0.1.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90624805fe29075cadd5a0ec5a359a1818f5429946d09d6a36f318a14479feb9
BLAKE2b-256 checksum
How to use checksums
3c8457b420d377a0b9d647d0963e6d50bac159ab338e05186eb5e30b8a7a7583
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for reactflow 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page