A modular Python library for structured adversarial agentic reasoning with multiple independent agents, RAG integration, and Chain-of-Thought data generation.
- Multiple Independent Agents: Each agent has unique prompts, perspectives, and optional RAG sources
- Structured Adversarial Critique: Agents critique each other's answers across logical, factual, and completeness dimensions
- Evaluator Synthesis: Final judge agent synthesizes the best elements into a refined verdict
- RAG Integration: FAISS-based vector storage for document retrieval (PDF, TXT, MD)
- Agent Memory: Configurable conversation history per agent or shared memory pools
- COT Data Generation: Capture deliberation process for Chain-of-Thought training data
Query → Independent Agents → Argument Layer → Evaluator → Verdict
(with RAG) (Critiques) (Synthesis)
- Independence before interaction: Agents generate answers in isolation
- Structured argumentation: Constrained, role-based critique formats
- Asymmetric information flow: Only evaluator sees all answers and critiques
- Knowledge grounding: Each agent can use its own Content DB and Local RAG
# Clone the repository
git clone <repository-url>
cd talecom_AI
# Install dependencies
pip install -r requirements.txtopenai>=1.0.0- LLM clientpydantic>=2.0.0- Data validationfaiss-cpu>=1.7.4- Vector storagesentence-transformers>=2.2.0- EmbeddingsPyPDF2>=3.0.0- PDF processingpandas>=2.0.0- Data processing (for COT export)pyarrow>=10.0.0- Parquet support
from src.core import Agent, infer, Argument
# Configuration
LLM_PARAMS = {
"modelName": "Qwen/Qwen2.5-7B-Instruct",
"url": "http://127.0.0.1:8010/v1",
"apiKey": "EMPTY"
}
# Create agents
AGENT_1 = Agent(
prompt="You are a conservative analyst...",
source_files=["docs/report.pdf"], # Optional RAG
llm_params=LLM_PARAMS,
memory=True # Enable conversation memory
)
AGENT_2 = Agent(
prompt="You are an optimistic strategist...",
llm_params=LLM_PARAMS,
memory=True
)
AGENTS = [AGENT_1, AGENT_2]
# Phase 1: Independent answers
query = "Should we migrate to microservices?"
level_1_results = infer(AGENTS, query)
# Phase 2: Argumentation
ARGUMENT_INSTRUCTION = "Critique each other's answers..."
argument_level = Argument(ARGUMENT_INSTRUCTION, AGENTS, level_1_results)
# Phase 3: Judge evaluation
JUDGE = Agent(
prompt="You are the final judge...",
llm_params=LLM_PARAMS,
agenttype='judge'
)
final_answer = infer([JUDGE], argument_level)
print(final_answer[0].answer)# Agent with document sources
agent = Agent(
prompt="You are a domain expert...",
source_files=[
"docs/technical_spec.pdf",
"docs/case_studies.txt",
"docs/notes.md"
],
llm_params=LLM_PARAMS,
memory=True
)from src.core import SharedMemory
# Create shared memory pool
shared = SharedMemory()
agent_1 = Agent(
prompt="You are a researcher...",
llm_params=LLM_PARAMS,
shared_memory=shared # Agents share memory
)
agent_2 = Agent(
prompt="You are a reviewer...",
llm_params=LLM_PARAMS,
shared_memory=shared # Same shared memory
)talecom_AI/
├── main.py # Main pipeline example
├── generate_cot_data.py # COT data generation example
├── requirements.txt # Dependencies
├── README.md # This file
└── src/
├── core/ # Simplified agent API
│ ├── agent.py # Agent class
│ ├── inference.py # infer() function
│ ├── argument.py # Argument class
│ └── memory.py # Memory system
├── cot/ # COT data generation
│ ├── collector.py # Data collection
│ ├── formatter.py # Data formatting
│ └── exporter.py # Export to JSONL/JSON/Parquet
├── agents/ # Advanced agent implementations
├── RAG/ # RAG components
│ ├── document_loader.py
│ ├── chunker.py
│ ├── embedder.py
│ └── faiss_store.py
├── prompts/ # Prompt templates
├── pipeline/ # Pipeline orchestration
└── schemas/ # Data models
See main.py for a complete example with:
- 4 agents with different perspectives
- Structured argumentation phase
- Final judge synthesis
See generate_cot_data.py for generating Chain-of-Thought training data:
from src.cot import COTCollector, COTExporter
collector = COTCollector(model_name="Qwen/Qwen2.5-7B-Instruct")
# Run pipeline and collect data
result = collector.run(AGENTS, query, ARGUMENT_INSTRUCTION, JUDGE)
# Export in all formats
COTExporter.export_all(
records=collector.get_records(),
output_dir="./cot_data/",
formats=["jsonl", "json", "parquet"]
)Agent(
prompt: str, # System prompt
llm_params: dict, # LLM configuration
source_files: list[str] = None, # RAG source files
memory: bool = False, # Enable memory
shared_memory: SharedMemory = None, # Use shared memory
agenttype: str = "default", # Agent type
name: str = None, # Agent name
)results = infer(
agents: list[Agent],
query: Union[str, InferenceResults, ArgumentResult],
additional_context: str = "",
verbose: bool = False
) -> InferenceResultsargument = Argument(
instruction: str, # Argumentation rules
agents: list[Agent],
previous_results: InferenceResults,
verbose: bool = False
)- PDF:
.pdffiles (requires PyPDF2) - Text:
.txtfiles - Markdown:
.md,.markdownfiles
- JSONL: One JSON object per line (ideal for fine-tuning)
- JSON: Structured JSON files (human-readable)
- Parquet: Columnar format (efficient for large datasets)
The library works with any OpenAI-compatible API. For local models:
# Using vLLM
python -m vllm.entrypoints.api_server \
--model Qwen/Qwen2.5-7B-Instruct \
--port 8010Then configure:
LLM_PARAMS = {
"modelName": "Qwen/Qwen2.5-7B-Instruct",
"url": "http://127.0.0.1:8010/v1",
"apiKey": "EMPTY"
}# Judge agent
judge = Agent(
prompt="You are the final judge...",
llm_params=LLM_PARAMS,
agenttype='judge'
)
# Critic agent
critic = Agent(
prompt="You are a logical critic...",
llm_params=LLM_PARAMS,
agenttype='critic'
)from src.RAG import FAISSStore, DocumentLoader, TextChunker
# Custom RAG setup
loader = DocumentLoader()
documents = loader.load_directory("./docs/")
chunker = TextChunker(chunk_size=1000, chunk_overlap=200)
chunks = []
for doc in documents:
chunks.extend(chunker.chunk_text(doc.content, source=doc.source))
store = FAISSStore(store_id="custom")
store.add_chunks(chunks)
# Use with agent
agent = Agent(
prompt="...",
llm_params=LLM_PARAMS,
rag_store=store # Use pre-built store
)Contributions are welcome! Please feel free to submit a Pull Request.
[Add your license here]
If you use this library in your research, please cite:
@software{adversarial_agents,
title = {Adversarial Multi-Agent Reasoning Library},
author = {Your Name},
year = {2024},
url = {https://github.com/yourusername/talecom_AI}
}- Inspired by debate-style alignment and reviewer-author workflows
- Built on OpenAI-compatible APIs and FAISS vector storage