Welcome to ReAgent, a non-monotonic, multi-agent architecture for complex multi-hop reasoning.
ReAgent (Reversible Multi-Agent Reasoning) is designed to solve knowledge-intensive, multi-hop questions with a team of specialized agents. It bridges the gap between purely forward-chaining solutions (which can accumulate errors) and real-world needs for flexible, non-monotonic updates. Agents can locally backtrack or escalate to global supervisors if a contradiction arises, restoring the entire system to a previously consistent state.
This framework emphasizes:
- Full Reversibility: Mistakes at any stage can be rolled back—locally or globally—based on conflict signals.
- Layered Modularity: The code cleanly separates Execution, Supervisory, and Interaction layers, mapping directly to the theoretical constructs outlined in the accompanying paper.
- Multi-Agent Concurrency: Agents communicate through a shared message pool and can run in parallel time steps, enabling dynamic merging of partial inferences.
- Adaptive Collaboration: Roles such as Thinker or BlackSheep demonstrate how the system can incorporate adversarial or user-driven logic to enhance or stress-test the reasoning process.
-
Non-Monotonic Architecture
Supports partial or holistic rollback upon conflict detection, improving robustness in domains where incomplete or contradictory information is common. -
Multi-Temporal Concurrency
Each agent operates in discrete time steps, saving snapshots for potential reversion. This design integrates with conflict resolution mechanisms in large-scale multi-hop tasks. -
Layered Design
- Execution Layer: Agents that handle domain tasks (question decomposition, retrieval, verification, and assembling answers).
- Supervisory Layer: Agents that orchestrate conflict management (for example, Supervisor or Controller).
- Interaction Layer: Manages message buses and concurrency models for all message passing and event merging.
-
Extensible Agent Roles
Additional roles like Human (a human-in-the-loop agent) and BlackSheep (an adversarial agent) show how to integrate optional behaviors for testing or manual intervention.
ReAgent/
├── Agent/
│ ├── agent.py
│ ├── blacksheep.py
│ ├── human.py
│ ├── moderator.py
│ ├── moderator2.py
│ ├── thinker.py
│ └── ...
├── Environment/
│ ├── environment.py
│ ├── groupchat.py
│ └── ...
├── Interaction/
│ ├── message.py
│ ├── messagepool.py
│ └── ...
├── DataProcess/
│ ├── Dataset.py
│ ├── Document.py
│ ├── Hotpotqa.py
│ └── ...
├── backend/
│ ├── api.py
│ └── ...
└── README.md
Below is a high-level scenario for a single run using main.py:
-
Load Dataset (e.g., HotpotQA)
AHotpotqaDataset(...)object is created to manage tasks containing questions, context paragraphs, and supporting facts. -
Initialize Agents
The system creates baseline roles (Decomposer, Retriever, Verifier, AnswerAssembler, Supervisor, Controller) plus optional roles (Thinker, BlackSheep, Human). -
Set Up the Environment
AnEnvironmentorGroupChatEnvironmentis created with concurrency, message passing, and time-step snapshots. -
Run Moderator
A Moderator (or Moderator2) agent coordinates stepwise chain-of-thought with partial or final answers.- If MAS is enabled, it checks votes from other agents to decide whether a reasoning step needs revision.
-
Conflict & Backtracking
- If a conflict arises (e.g., an agent detects a contradiction), it attempts local backtracking or notifies the environment.
- The environment triggers a global revert if multiple conflicts occur or if a supervisory signal is raised.
-
Conclude
Once the system arrives at a final answer (or hits a time limit), the environment merges all partial results. The AnswerAssembler constructs the final solution.
-
Dependencies
- Python 3.8+
- Basic Python libraries (for instance,
copy,time,json) - Optionally, advanced libraries for deep learning or LLM calls (such as
openai,requests)
-
Run
python main.py
This will build agents, initialize the environment, optionally load data, and then proceed through the chain-of-thought reasoning steps.
-
Configuration
- Modify the
Argsclass inmain.pyto specify your dataset path (args.dataset_path) or adjust model names, concurrency flags, and trust disclaimers (args.truth).
- Modify the
-
Adapting
- For a simpler pipeline, omit Human or BlackSheep.
- For advanced concurrency, use
run_time_steporrun_until_stablemethods in the environment.