Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import yaml
import time
import threading
import random

from concurrent.futures import ThreadPoolExecutor, as_completed
from typing import List, Dict, Any
from agent import OpenRouterAgent


class TaskOrchestrator:
def __init__(self, config_path="config.yaml", silent=False):
# Load configuration
Expand Down Expand Up @@ -53,13 +56,22 @@ def decompose_task(self, user_input: str, num_agents: int) -> List[str]:
return questions

except (json.JSONDecodeError, ValueError) as e:
# Fallback: create simple variations if AI fails
return [
# Fallback: create random shuffled variations if AI fails
fallback_templates = [
f"Research comprehensive information about: {user_input}",
f"Analyze and provide insights about: {user_input}",
f"Find alternative perspectives on: {user_input}",
f"Verify and cross-check facts about: {user_input}"
][:num_agents]
f"Verify and cross-check facts about: {user_input}",
]
random.shuffle(fallback_templates)
# If more agents than templates, repeat and shuffle again
result = []
while len(result) < num_agents:
needed = num_agents - len(result)
to_add = fallback_templates[:needed]
random.shuffle(to_add)
result.extend(to_add)
return result[:num_agents]

def update_agent_progress(self, agent_id: int, status: str, result: str = None):
"""Thread-safe progress tracking"""
Expand Down