- name
- logos-distributed-reasoning-router
- description
- Deploy and use Logos Router for zero-drift distributed AI reasoning with adaptive Claude Opus-style thinking and multilingual semantic routing
- triggers
- ["how do I set up Logos Router for distributed reasoning","configure a reasoning mesh with zero drift consensus","use Logos Router for multi-step AI workflows","implement strict write discipline with Logos","create adaptive reasoning nodes with Logos Router","troubleshoot Logos Router mesh consensus","set up multilingual semantic routing with Logos","deploy local reasoning infrastructure with zero drift"]
# Logos Distributed Reasoning Router
> Skill by [ara.so](https://ara.so) — MCP Skills collection.
## Overview
Logos Router is a distributed semantic reasoning gateway that eliminates AI reasoning "drift" by fragmenting inference across local nodes with zero-drift consensus guarantees. Instead of funneling all reasoning through a single model, it distributes subproblems across a mesh of reasoning units that coordinate through a Strict Write Discipline (SWD) protocol. Every reasoning step is verified by multiple nodes before being committed, creating an immutable DAG of cognition with causal audit trails.
**Key Features:**
- **Zero-drift consensus**: Cross-validation prevents hallucination chains
- **Adaptive reasoning depth**: Automatically escalates complexity for hard problems
- **Multilingual support**: 16 languages with universal semantic representation
- **24/7 continuity**: Mesh resilience with transparent failover
- **Local sovereignty**: All reasoning runs on your infrastructure
- **Causal audit trails**: Complete lineage of every routing decision
## Installation
### Prerequisites
- Python 3.11 or later
- At least one local inference engine (VLLM, Ollama, llama.cpp, etc.)
- Network access between mesh nodes (localhost works for single-machine)
### Install from Source
```bash
# Clone the repository
git clone https://github.com/rak7777/mythic-mcp-proxy.git
cd mythic-mcp-proxy
# Install dependencies
pip install -r requirements.txt
# Install the router package
pip install -e .
```
### Verify Installation
```python
from logos import Router
print(Router.version())
```
## Configuration
### Basic Mesh Configuration
Create a YAML configuration file defining your reasoning mesh topology:
```yaml
# config/basic_mesh.yaml
mesh:
name: local-reasoning-mesh
consensus_threshold: 0.95 # 95% confidence required before commit
nodes:
- type: local
engine: vllm
model: opus-mini-4.8
max_thinking_depth: 7
host: localhost
port: 8000
- type: local
engine: ollama
model: llama3-70b
max_thinking_depth: 5
host: localhost
port: 11434
languages:
- en
- zh
- es
- fr
- de
```
### Advanced Configuration with Multiple Nodes
```yaml
# config/advanced_mesh.yaml
mesh:
name: distributed-thought-lattice
consensus_threshold: 0.95
max_concurrent_queries: 50
semantic_cache_size: 1024 # MB
nodes:
- name: primary-reasoner
type: local
engine: vllm
model: opus-mini-4.8
max_thinking_depth: 7
capabilities:
- deep_reasoning
- code_analysis
- mathematical_proof
- name: verification-node
type: local
engine: ollama
model: mixtral-8x7b
max_thinking_depth: 5
capabilities:
- fact_checking
- logical_consistency
- name: synthesis-node
type: local
engine: llama.cpp
model: llama3-70b
max_thinking_depth: 6
capabilities:
- summarization
- harmonization
reasoning:
strict_write_discipline: true
verification_peer_count: 2
escalation_threshold: 0.85
graceful_degradation: true
languages:
- en
- zh
- es
- ar
- hi
- fr
- de
- ja
- ko
- pt
- ru
storage:
grail_layer_path: ./reasoning_states
max_history_days: 90
compression: true
```
## Core API Usage
### Basic Query Routing
```python
from logos import Router
# Initialize router with configuration
router = Router(config="config/basic_mesh.yaml")
# Single query with adaptive reasoning
response = router.query(
prompt="Explain the halting problem and its implications for AI safety",
depth="adaptive", # Can be "adaptive", 1-7, or "minimal"
language="en"
)
print(response.text)
print(f"Reasoning depth used: {response.depth}")
print(f"Nodes consulted: {response.nodes_involved}")
print(f"Consensus score: {response.consensus_score}")
print(f"Verification steps: {len(response.audit_trail)}")
```
### Multi-Step Workflow
```python
from logos import Router, Workflow
router = Router(config="config/advanced_mesh.yaml")
# Create a workflow for complex multi-step reasoning
workflow = router.create_workflow(
name="research_paper_analysis",
consensus=True # Enable strict consensus at each step
)
# Define workflow steps
workflow.add_step(
"extract_claims",
prompt="Extract all factual claims from this document",
input_file="papers/ai_safety_paper.pdf",
depth=5
)
workflow.add_step(
"verify_claims",
prompt="Verify each claim against known literature",
depends_on="extract_claims",
depth=7,
require_consensus=True
)
workflow.add_step(
"generate_summary",
prompt="Synthesize findings into an academic summary",
depends_on="verify_claims",
depth=6,
style="academic"
)
# Execute workflow (blocks until complete)
result = workflow.execute()
print(f"Workflow completed in {result.duration_seconds}s")
print(f"Total reasoning steps: {result.total_steps}")
print(f"Consensus failures: {result.consensus_failures}")
print(result.final_output)
```
### Streaming Reasoning Steps
```python
from logos import Router
router = Router(config="config/basic_mesh.yaml")
# Stream reasoning steps in real-time
for step in router.query_stream(
prompt="Design a distributed consensus algorithm for Byzantine fault tolerance",
depth="adaptive"
):
print(f"[Node {step.node_id}] Depth {step.current_depth}: {step.text}")
print(f" Confidence: {step.confidence:.2%}")
if step.requires_escalation:
print(f" ⚠️ Escalating to higher reasoning depth")
if step.consensus_reached:
print(f" ✓ Consensus reached ({step.consensus_score:.2%})")
```
### Multilingual Reasoning
```python
from logos import Router
router = Router(config="config/advanced_mesh.yaml")
# Query in Chinese, get response in Chinese
response = router.query(
prompt="解释量子纠缠如何影响信息理论",
language="zh",
depth=6
)
print(response.text) # Response in Chinese
# Query in Spanish, request response in English
response = router.query(
prompt="¿Cómo funcionan las redes neuronales convolucionales?",
input_language="es",
output_language="en",
depth=5
)
print(response.text) # Response in English
```
## Strict Write Discipline (SWD)
### Understanding SWD Protocol
The Strict Write Discipline protocol ensures zero-drift reasoning:
1. **Proposal**: Node generates candidate reasoning step
2. **Broadcast**: Candidate sent to peer nodes for verification
3. **Verification**: Peers check logical consistency and factual accuracy
4. **Consensus**: Step committed if confidence exceeds threshold
5. **Escalation**: Failed consensus triggers higher-depth arbitration
### Inspecting SWD Audit Trails
```python
from logos import Router
router = Router(config="config/advanced_mesh.yaml")
response = router.query(
prompt="Prove that the set of real numbers is uncountable",
depth="adaptive"
)
# Examine complete reasoning trail
for i, step in enumerate(response.audit_trail):
print(f"\n=== Step {i+1} ===")
print(f"Node: {step.node_id}")
print(f"Proposal: {step.proposal}")
print(f"Peer verifications: {step.peer_count}")
print(f"Consensus score: {step.consensus_score:.2%}")
print(f"Committed: {step.committed}")
if step.escalated:
print(f"⚠️ Escalated to depth {step.escalation_depth}")
print(f"Arbiter: {step.arbiter_node}")
```
### Configuring SWD Parameters
```python
from logos import Router, SWDConfig
swd_config = SWDConfig(
consensus_threshold=0.97, # Require 97% consensus
verification_peer_count=3, # Use 3 peers for verification
escalation_threshold=0.80, # Escalate if below 80%
max_escalation_depth=9, # Maximum depth for escalation
timeout_seconds=30 # Timeout for peer verification
)
router = Router(
config="config/basic_mesh.yaml",
swd_config=swd_config
)
```
## CLI Usage
### Basic Commands
```bash
# Start the reasoning mesh
logos start --config config/basic_mesh.yaml
# Query the mesh from CLI
logos query "Explain the Church-Turing thesis" --depth adaptive
# Query with specific language
logos query "Qu'est-ce que l'intelligence artificielle?" --language fr
# Run a workflow from file
logos workflow run workflows/paper_analysis.yaml
# Check mesh status
logos status
# View reasoning audit trail
logos audit --query-id abc123-def456
# Stop the mesh
logos stop
```
### Advanced CLI Options
```bash
# Query with custom consensus threshold
logos query "Design a consensus algorithm" \
--depth 7 \
--consensus-threshold 0.98 \
--peers 4
# Stream reasoning steps to console
logos query "Prove the Pythagorean theorem" \
--stream \
--show-consensus
# Export reasoning trail to JSON
logos audit --query-id abc123 --format json > trail.json
# Benchmark mesh performance
logos benchmark --queries 100 --depth adaptive
# Add a new node to running mesh
logos node add \
--engine ollama \
--model llama3-70b \
--host localhost \
--port 11434
```
## REST API Integration
### Starting API Server
```python
from logos import Router, APIServer
router = Router(config="config/advanced_mesh.yaml")
# Start REST API server
server = APIServer(router, host="0.0.0.0", port=8080)
server.start()
```
### API Endpoints
```python
import requests
import json
# Submit a query
response = requests.post(
"http://localhost:8080/query",
json={
"prompt": "Explain gradient descent optimization",
"depth": "adaptive",
"language": "en",
"stream": False
}
)
result = response.json()
print(result["text"])
print(f"Consensus: {result['consensus_score']}")
# Get query status
status = requests.get(f"http://localhost:8080/query/{result['query_id']}")
print(status.json())
# Stream reasoning steps via WebSocket
import websocket
ws = websocket.create_connection("ws://localhost:8080/query/stream")
ws.send(json.dumps({
"prompt": "Design a distributed database",
"depth": 7
}))
while True:
step = json.loads(ws.recv())
if step["type"] == "complete":
break
print(f"Step: {step['text']} (confidence: {step['confidence']})")
ws.close()
```
## Common Patterns
### Pattern: Code Review with Consensus
```python
from logos import Router
router = Router(config="config/advanced_mesh.yaml")
def review_code_with_consensus(code_file_path):
workflow = router.create_workflow(
name="code_review",
consensus=True
)
workflow.add_step(
"analyze_structure",
prompt=f"Analyze code structure and architecture in {code_file_path}",
depth=5
)
workflow.add_step(
"identify_issues",
prompt="Identify potential bugs, security issues, and code smells",
depends_on="analyze_structure",
depth=7,
require_consensus=True
)
workflow.add_step(
"suggest_improvements",
prompt="Suggest specific improvements with code examples",
depends_on="identify_issues",
depth=6
)
result = workflow.execute()
return result
# Use the pattern
review = review_code_with_consensus("src/main.py")
print(review.final_output)
```
### Pattern: Multi-Language Documentation Generation
```python
from logos import Router
router = Router(config="config/advanced_mesh.yaml")
def generate_multilingual_docs(source_code, target_languages):
base_response = router.query(
prompt=f"Generate comprehensive API documentation for this code:\n\n{source_code}",
language="en",
depth=6
)
docs = {"en": base_response.text}
for lang in target_languages:
translated = router.query(
prompt=f"Translate this technical documentation, preserving all code examples:\n\n{base_response.text}",
input_language="en",
output_language=lang,
depth=4
)
docs[lang] = translated.text
return docs
# Generate docs in multiple languages
docs = generate_multilingual_docs(
source_code=open("api.py").read(),
target_languages=["zh", "es", "fr", "de", "ja"]
)
for lang, content in docs.items():
with open(f"docs/api_{lang}.md", "w") as f:
f.write(content)
```
### Pattern: Resilient Long-Running Analysis
```python
from logos import Router
import time
router = Router(config="config/advanced_mesh.yaml")
def analyze_large_dataset_with_checkpoints(dataset_path):
workflow = router.create_workflow(
name="dataset_analysis",
checkpoint_interval=10 # Checkpoint every 10 steps
View on GitHub