diff --git a/backend/app/api/v1/__pycache__/routes.cpython-313.pyc b/backend/app/api/v1/__pycache__/routes.cpython-313.pyc index 42d0ba2..e01f4d2 100644 Binary files a/backend/app/api/v1/__pycache__/routes.cpython-313.pyc and b/backend/app/api/v1/__pycache__/routes.cpython-313.pyc differ diff --git a/backend/app/core/__pycache__/logger.cpython-313.pyc b/backend/app/core/__pycache__/logger.cpython-313.pyc index 70511bf..56d8e37 100644 Binary files a/backend/app/core/__pycache__/logger.cpython-313.pyc and b/backend/app/core/__pycache__/logger.cpython-313.pyc differ diff --git a/backend/app/core/__pycache__/orchestrator.cpython-313.pyc b/backend/app/core/__pycache__/orchestrator.cpython-313.pyc index 02c610a..bc867f6 100644 Binary files a/backend/app/core/__pycache__/orchestrator.cpython-313.pyc and b/backend/app/core/__pycache__/orchestrator.cpython-313.pyc differ diff --git a/backend/app/core/__pycache__/storage.cpython-313.pyc b/backend/app/core/__pycache__/storage.cpython-313.pyc new file mode 100644 index 0000000..ebe8b55 Binary files /dev/null and b/backend/app/core/__pycache__/storage.cpython-313.pyc differ diff --git a/backend/app/core/orchestrator.py b/backend/app/core/orchestrator.py index a0f2b5a..238fcd7 100644 --- a/backend/app/core/orchestrator.py +++ b/backend/app/core/orchestrator.py @@ -54,6 +54,7 @@ async def execute_agents(self, report_id: str, token_id: str) -> Dict[str, Any]: except Exception as e: orchestrator_logger.exception("Agent %s failed for report %s", name, report_id) results[name] = {"status": "failed", "error": str(e)} + raise # Re-raise the exception return results def aggregate_results(self, results: Dict[str, Any]) -> Dict[str, Any]: @@ -65,7 +66,11 @@ def aggregate_results(self, results: Dict[str, Any]) -> Dict[str, Any]: Returns: The aggregated result. """ - return {"agent_results": results} + aggregated_data = {} + for agent_name, agent_result in results.items(): + if agent_result["status"] == "completed" and "data" in agent_result: + aggregated_data.update(agent_result["data"]) + return aggregated_data class Orchestrator(AIOrchestrator): """ diff --git a/backend/app/core/storage.py b/backend/app/core/storage.py index 8ca98f4..1130e37 100644 --- a/backend/app/core/storage.py +++ b/backend/app/core/storage.py @@ -1,21 +1,41 @@ +import threading + REPORT_STORE = {} +_report_store_lock = threading.Lock() def set_report_status(report_id: str, status: str): """Sets the status of a report.""" - if report_id not in REPORT_STORE: - REPORT_STORE[report_id] = {"status": status, "data": None} - else: - REPORT_STORE[report_id]["status"] = status + with _report_store_lock: + if report_id not in REPORT_STORE: + REPORT_STORE[report_id] = {"status": status, "data": None} + else: + REPORT_STORE[report_id]["status"] = status def get_report_status(report_id: str) -> str | None: """Gets the status of a report.""" - return REPORT_STORE.get(report_id, {}).get("status") + with _report_store_lock: + return REPORT_STORE.get(report_id, {}).get("status") + +def try_set_processing(report_id: str) -> bool: + """ + Atomically checks if a report is not processing and, if so, sets its status to "processing". + Returns True if successful, False otherwise. + """ + with _report_store_lock: + if REPORT_STORE.get(report_id, {}).get("status") != "processing": + if report_id not in REPORT_STORE: + REPORT_STORE[report_id] = {"status": "processing", "data": None} + else: + REPORT_STORE[report_id]["status"] = "processing" + return True + return False def save_report_data(report_id: str, data: dict): """Saves the data for a report.""" - if report_id not in REPORT_STORE: - REPORT_STORE[report_id] = {"status": "completed", "data": data} - else: - REPORT_STORE[report_id]["data"] = data - REPORT_STORE[report_id]["status"] = "completed" + with _report_store_lock: + if report_id not in REPORT_STORE: + REPORT_STORE[report_id] = {"status": "completed", "data": data} + else: + REPORT_STORE[report_id]["data"] = data + REPORT_STORE[report_id]["status"] = "completed" diff --git a/backend/app/services/__pycache__/report_processor.cpython-313-pytest-8.4.2.pyc b/backend/app/services/__pycache__/report_processor.cpython-313-pytest-8.4.2.pyc new file mode 100644 index 0000000..f1519e2 Binary files /dev/null and b/backend/app/services/__pycache__/report_processor.cpython-313-pytest-8.4.2.pyc differ diff --git a/backend/app/services/__pycache__/report_processor.cpython-313.pyc b/backend/app/services/__pycache__/report_processor.cpython-313.pyc index a0ecef5..23343ce 100644 Binary files a/backend/app/services/__pycache__/report_processor.cpython-313.pyc and b/backend/app/services/__pycache__/report_processor.cpython-313.pyc differ diff --git a/backend/app/services/__pycache__/report_service.cpython-313.pyc b/backend/app/services/__pycache__/report_service.cpython-313.pyc index 904f91a..b04c106 100644 Binary files a/backend/app/services/__pycache__/report_service.cpython-313.pyc and b/backend/app/services/__pycache__/report_service.cpython-313.pyc differ diff --git a/backend/app/services/agents/__pycache__/__init__.cpython-313.pyc b/backend/app/services/agents/__pycache__/__init__.cpython-313.pyc index 7c96c3b..ed72993 100644 Binary files a/backend/app/services/agents/__pycache__/__init__.cpython-313.pyc and b/backend/app/services/agents/__pycache__/__init__.cpython-313.pyc differ diff --git a/backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc b/backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc new file mode 100644 index 0000000..121024f Binary files /dev/null and b/backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc differ diff --git a/backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc b/backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc new file mode 100644 index 0000000..e408fe7 Binary files /dev/null and b/backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc differ diff --git a/backend/app/services/agents/__pycache__/volume_agent.cpython-313.pyc b/backend/app/services/agents/__pycache__/volume_agent.cpython-313.pyc index 1cedffd..e54d721 100644 Binary files a/backend/app/services/agents/__pycache__/volume_agent.cpython-313.pyc and b/backend/app/services/agents/__pycache__/volume_agent.cpython-313.pyc differ diff --git a/backend/app/services/agents/price_agent.py b/backend/app/services/agents/price_agent.py index e0eaede..b280749 100644 --- a/backend/app/services/agents/price_agent.py +++ b/backend/app/services/agents/price_agent.py @@ -1,8 +1,8 @@ import asyncio -async def run(token_id: str): +async def run(report_id: str, token_id: str): """ Mocks fetching price data for a given token. """ await asyncio.sleep(0.1) # Simulate a small delay - return {"price": 123.45, "token_id": token_id} + return {"price": 123.45, "token_id": token_id, "report_id": report_id} diff --git a/backend/app/services/agents/trend_agent.py b/backend/app/services/agents/trend_agent.py index f6a5482..90a8fc6 100644 --- a/backend/app/services/agents/trend_agent.py +++ b/backend/app/services/agents/trend_agent.py @@ -1,8 +1,8 @@ import asyncio -async def run(token_id: str): +async def run(report_id: str, token_id: str): """ Mocks fetching trend data for a given token. """ await asyncio.sleep(0.1) # Simulate a small delay - return {"trend": "up", "change_24h": 5.67, "token_id": token_id} + return {"trend": "up", "change_24h": 5.67, "token_id": token_id, "report_id": report_id} diff --git a/backend/app/services/agents/volume_agent.py b/backend/app/services/agents/volume_agent.py index c4dd342..cc281ec 100644 --- a/backend/app/services/agents/volume_agent.py +++ b/backend/app/services/agents/volume_agent.py @@ -1,8 +1,8 @@ import asyncio -async def run(token_id: str): +async def run(report_id: str, token_id: str): """ Mocks fetching volume data for a given token. """ await asyncio.sleep(0.1) # Simulate a small delay - return {"volume": 987654.32, "token_id": token_id} + return {"volume": 987654.32, "token_id": token_id, "report_id": report_id} diff --git a/backend/app/services/report_processor.py b/backend/app/services/report_processor.py index 9e05953..82d93fd 100644 --- a/backend/app/services/report_processor.py +++ b/backend/app/services/report_processor.py @@ -1,15 +1,14 @@ import asyncio import logging +from backend.app.core.orchestrator import AIOrchestrator +from backend.app.services.agents.price_agent import run as price_agent_run +from backend.app.services.agents.trend_agent import run as trend_agent_run +from backend.app.services.agents.volume_agent import run as volume_agent_run +from backend.app.core.storage import save_report_data, set_report_status, try_set_processing logger = logging.getLogger(__name__) -# In a real application, this would be a more robust shared state management system (e.g., Redis, a database, or a dedicated in-memory store with proper locking). -# For now, a simple dictionary will simulate the state. -# NOTE: This in-memory lock is only suitable for single-process deployments. -# For multi-process or distributed deployments, consider using an external store -# like Redis or a database with appropriate distributed locking mechanisms. -report_status = {} -report_status_lock = asyncio.Lock() + async def process_report(report_id: str, token_id: str) -> bool: """ @@ -22,36 +21,31 @@ async def process_report(report_id: str, token_id: str) -> bool: Returns: True on success. """ - # Mark processing under lock - async with report_status_lock: - if report_id in report_status: - raise ValueError(f"Report {report_id} is already being processed") - report_status[report_id] = {"status": "processing", "token_id": token_id} - logger.info("Processing report %s for token %s", report_id, token_id) + if not try_set_processing(report_id): + logger.info("Report %s is already being processed, skipping.", report_id) + raise ValueError(f"Report {report_id} is already being processed") + + logger.info("Processing report %s for token %s", report_id, token_id) try: - await asyncio.sleep(5) # Simulate work - async with report_status_lock: - if report_id in report_status and isinstance(report_status[report_id], dict): - report_status[report_id]["status"] = "completed" + orchestrator = AIOrchestrator() + orchestrator.register_agent("price_agent", price_agent_run) + orchestrator.register_agent("trend_agent", trend_agent_run) + orchestrator.register_agent("volume_agent", volume_agent_run) + + agent_results = await orchestrator.execute_agents(report_id, token_id) + combined_report_data = orchestrator.aggregate_results(agent_results) + + save_report_data(report_id, combined_report_data) + set_report_status(report_id, "completed") + logger.info("Report %s completed.", report_id) return True except asyncio.CancelledError: - async with report_status_lock: - if report_id in report_status: - report_status[report_id]["status"] = "cancelled" + set_report_status(report_id, "cancelled") raise except Exception: - async with report_status_lock: - if report_id in report_status: - report_status[report_id]["status"] = "failed" - logger.exception("Report %s failed.", report_id) - raise - -async def get_report_status(report_id: str): - """ - Retrieves the status of a report. - """ - async with report_status_lock: - return report_status.get(report_id) \ No newline at end of file + logger.exception("Error processing report %s for token %s", report_id, token_id) + set_report_status(report_id, "failed") + raise \ No newline at end of file diff --git a/backend/app/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc b/backend/app/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc new file mode 100644 index 0000000..abaad7e Binary files /dev/null and b/backend/app/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc differ diff --git a/backend/app/tests/test_report_processor.py b/backend/app/tests/test_report_processor.py new file mode 100644 index 0000000..77b88cb --- /dev/null +++ b/backend/app/tests/test_report_processor.py @@ -0,0 +1,112 @@ +import pytest +import threading +import asyncio +from unittest.mock import patch + +from backend.app.services.report_processor import process_report +from backend.app.core import storage + +@pytest.fixture(autouse=True) +def clear_report_store(): + storage.REPORT_STORE.clear() + +@pytest.mark.asyncio +async def test_process_report_success(): + report_id = "test_report_1" + token_id = "test_token_1" + + # Mock the agents to prevent actual external calls + with patch('backend.app.services.report_processor.price_agent_run') as mock_price_agent_run: + with patch('backend.app.services.report_processor.volume_agent_run') as mock_volume_agent_run: + with patch('backend.app.services.report_processor.trend_agent_run') as mock_trend_agent_run: + + mock_price_agent_run.return_value = {"price": 100.0, "token_id": token_id, "report_id": report_id} + mock_volume_agent_run.return_value = {"volume": 1000.0, "token_id": token_id, "report_id": report_id} + mock_trend_agent_run.return_value = {"trend": "up", "token_id": token_id, "report_id": report_id} + + await process_report(report_id, token_id) + + assert storage.get_report_status(report_id) == "completed" + report_data = storage.REPORT_STORE[report_id]["data"] + assert report_data["price"] == 100.0 + assert report_data["volume"] == 1000.0 + assert report_data["trend"] == "up" + +@pytest.mark.asyncio +async def test_process_report_already_processing(): + report_id = "test_report_2" + token_id = "test_token_2" + storage.set_report_status(report_id, "processing") + + with pytest.raises(ValueError, match=f"Report {report_id} is already being processed"): + await process_report(report_id, token_id) + + assert storage.get_report_status(report_id) == "processing" + +@pytest.mark.asyncio +async def test_process_report_failure_sets_failed_status(): + report_id = "test_report_3" + token_id = "test_token_3" + + with patch('backend.app.services.report_processor.price_agent_run') as mock_price_agent_run: + mock_price_agent_run.side_effect = Exception("Agent error") + with pytest.raises(Exception, match="Agent error"): + await process_report(report_id, token_id) + + assert storage.get_report_status(report_id) == "failed" + +def test_try_set_processing_success(): + report_id = "new_report" + assert storage.try_set_processing(report_id) is True + assert storage.get_report_status(report_id) == "processing" + +def test_try_set_processing_failure_already_processing(): + report_id = "existing_report" + storage.set_report_status(report_id, "processing") + assert storage.try_set_processing(report_id) is False + assert storage.get_report_status(report_id) == "processing" + +def test_try_set_processing_failure_other_status(): + report_id = "existing_report_completed" + storage.set_report_status(report_id, "completed") + assert storage.try_set_processing(report_id) is True + assert storage.get_report_status(report_id) == "processing" + +def test_concurrent_processing_only_one_succeeds(): + report_id = "concurrent_report" + token_id = "concurrent_token" + + processed_count = 0 + exception_count = 0 + + def worker(): + nonlocal processed_count, exception_count + try: + # Mock the agents to prevent actual external calls + with patch('backend.app.services.report_processor.price_agent_run', return_value={"price": 100.0, "token_id": token_id, "report_id": report_id}): + with patch('backend.app.services.report_processor.volume_agent_run', return_value={"volume": 1000.0, "token_id": token_id, "report_id": report_id}): + with patch('backend.app.services.report_processor.trend_agent_run', return_value={"trend": "up", "token_id": token_id, "report_id": report_id}): + asyncio.run(process_report(report_id, token_id)) + processed_count += 1 + except ValueError as e: + if "already being processed" in str(e): + exception_count += 1 + else: + raise + except Exception: + # Catch other unexpected exceptions during processing + pass + + threads = [] + for _ in range(5): + thread = threading.Thread(target=worker) + threads.append(thread) + thread.start() + + for thread in threads: + thread.join() + + assert processed_count == 1 + assert exception_count == 4 + assert storage.get_report_status(report_id) == "completed" + assert "data" in storage.REPORT_STORE[report_id] diff --git a/backend/logs/app.log b/backend/logs/app.log index e300685..d772d8c 100644 --- a/backend/logs/app.log +++ b/backend/logs/app.log @@ -53,3 +53,745 @@ Exception: Agent failed 2025-10-29 06:43:32,606 - services - INFO - Attempting to retrieve data for report_id: non_existent_report 2025-10-29 06:43:32,606 - services - WARNING - Report with id non_existent_report not found when attempting to retrieve data. 2025-10-29 06:43:32,607 - api - ERROR - Report with id non_existent_report not found or not completed for data request. +2025-10-31 07:19:34,736 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:19:34,736 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:20:17,699 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:20:17,699 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:20:17,710 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:20:17,710 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:20:17,710 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:20:17,710 - orchestrator - INFO - Executing agents for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:20:17,710 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_success. +2025-10-31 07:20:17,710 - orchestrator - INFO - Agent AgentTwo completed for report test_report_id_success. +2025-10-31 07:20:17,710 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:20:17,710 - orchestrator - INFO - Report test_report_id_success status updated to completed. +2025-10-31 07:20:17,719 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:20:17,719 - orchestrator - INFO - Registering agent: AgentFailing +2025-10-31 07:20:17,719 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:20:17,719 - orchestrator - INFO - Executing agents for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:20:17,720 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_failure. +2025-10-31 07:20:17,720 - orchestrator - ERROR - Agent AgentFailing failed for report test_report_id_failure +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent failed +2025-10-31 07:20:17,725 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:20:17,725 - orchestrator - WARNING - Report test_report_id_failure completed with partial success due to agent failures. +2025-10-31 07:20:17,725 - orchestrator - INFO - Report test_report_id_failure status updated to partial_success. +2025-10-31 07:20:17,728 - orchestrator - INFO - Registering agent: a +2025-10-31 07:20:17,731 - orchestrator - INFO - Registering agent: dummy_agent +2025-10-31 07:21:13,518 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:21:13,519 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:21:20,714 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:21:20,715 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:21:20,728 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:21:20,728 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:21:20,728 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:21:20,728 - orchestrator - INFO - Executing agents for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:21:20,728 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_success. +2025-10-31 07:21:20,728 - orchestrator - INFO - Agent AgentTwo completed for report test_report_id_success. +2025-10-31 07:21:20,728 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:21:20,728 - orchestrator - INFO - Report test_report_id_success status updated to completed. +2025-10-31 07:21:20,736 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:21:20,736 - orchestrator - INFO - Registering agent: AgentFailing +2025-10-31 07:21:20,737 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:21:20,737 - orchestrator - INFO - Executing agents for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:21:20,737 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_failure. +2025-10-31 07:21:20,737 - orchestrator - ERROR - Agent AgentFailing failed for report test_report_id_failure +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent failed +2025-10-31 07:21:20,738 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:21:20,738 - orchestrator - WARNING - Report test_report_id_failure completed with partial success due to agent failures. +2025-10-31 07:21:20,739 - orchestrator - INFO - Report test_report_id_failure status updated to partial_success. +2025-10-31 07:21:20,740 - orchestrator - INFO - Registering agent: a +2025-10-31 07:21:20,742 - orchestrator - INFO - Registering agent: dummy_agent +2025-10-31 07:21:20,917 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:21:20,917 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:21:20,920 - api - INFO - Received data request for report_id: 5fb07e4d-34ac-46c9-975e-9bc9d8b2a066 +2025-10-31 07:21:20,921 - services - INFO - Attempting to retrieve data for report_id: 5fb07e4d-34ac-46c9-975e-9bc9d8b2a066 +2025-10-31 07:21:20,921 - services - INFO - Report 5fb07e4d-34ac-46c9-975e-9bc9d8b2a066 is in status: processing, returning status only. +2025-10-31 07:21:20,921 - api - WARNING - Report 5fb07e4d-34ac-46c9-975e-9bc9d8b2a066 is still processing. +2025-10-31 07:21:20,927 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:21:20,927 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:21:20,927 - orchestrator - INFO - Executing agents concurrently for report_id: 9920ea00-ec4b-447b-b051-650f2c04ef5a, token_id: test_token +2025-10-31 07:21:20,927 - orchestrator - INFO - Executing agents for report_id: 9920ea00-ec4b-447b-b051-650f2c04ef5a, token_id: test_token +2025-10-31 07:21:22,929 - orchestrator - INFO - Agent AgentOne completed for report 9920ea00-ec4b-447b-b051-650f2c04ef5a. +2025-10-31 07:21:22,929 - orchestrator - INFO - Agent AgentTwo completed for report 9920ea00-ec4b-447b-b051-650f2c04ef5a. +2025-10-31 07:21:22,929 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:21:22,930 - orchestrator - INFO - Report 9920ea00-ec4b-447b-b051-650f2c04ef5a status updated to completed. +2025-10-31 07:21:22,932 - api - INFO - Received status request for report_id: 9920ea00-ec4b-447b-b051-650f2c04ef5a +2025-10-31 07:21:22,932 - services - INFO - Retrieving status for report_id: 9920ea00-ec4b-447b-b051-650f2c04ef5a from memory. +2025-10-31 07:21:22,934 - api - INFO - Received data request for report_id: 9920ea00-ec4b-447b-b051-650f2c04ef5a +2025-10-31 07:21:22,934 - services - INFO - Attempting to retrieve data for report_id: 9920ea00-ec4b-447b-b051-650f2c04ef5a +2025-10-31 07:21:22,934 - services - INFO - Report 9920ea00-ec4b-447b-b051-650f2c04ef5a is completed, returning data. +2025-10-31 07:21:22,934 - api - INFO - Returning data for report_id: 9920ea00-ec4b-447b-b051-650f2c04ef5a +2025-10-31 07:21:22,941 - api - INFO - Received data request for report_id: non_existent_report +2025-10-31 07:21:22,942 - services - INFO - Attempting to retrieve data for report_id: non_existent_report +2025-10-31 07:21:22,942 - services - WARNING - Report with id non_existent_report not found when attempting to retrieve data. +2025-10-31 07:21:22,942 - api - ERROR - Report with id non_existent_report not found or not completed for data request. +2025-10-31 07:21:29,856 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:21:29,856 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:21:29,866 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:21:29,866 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:21:29,866 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:21:29,866 - orchestrator - INFO - Executing agents for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:21:29,866 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_success. +2025-10-31 07:21:29,866 - orchestrator - INFO - Agent AgentTwo completed for report test_report_id_success. +2025-10-31 07:21:29,866 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:21:29,866 - orchestrator - INFO - Report test_report_id_success status updated to completed. +2025-10-31 07:21:29,869 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:21:29,869 - orchestrator - INFO - Registering agent: AgentFailing +2025-10-31 07:21:29,869 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:21:29,869 - orchestrator - INFO - Executing agents for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:21:29,870 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_failure. +2025-10-31 07:21:29,870 - orchestrator - ERROR - Agent AgentFailing failed for report test_report_id_failure +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent failed +2025-10-31 07:21:29,871 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:21:29,871 - orchestrator - WARNING - Report test_report_id_failure completed with partial success due to agent failures. +2025-10-31 07:21:29,871 - orchestrator - INFO - Report test_report_id_failure status updated to partial_success. +2025-10-31 07:21:29,873 - orchestrator - INFO - Registering agent: a +2025-10-31 07:21:29,874 - orchestrator - INFO - Registering agent: dummy_agent +2025-10-31 07:21:29,876 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:21:29,876 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:21:29,876 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:21:29,876 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 07:21:29,911 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:21:29,911 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:21:29,911 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:21:29,911 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 07:21:30,021 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:21:30,022 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:21:30,022 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:21:30,022 - orchestrator - INFO - Executing agents for report_id: test_report_4, token_id: test_token_4 +2025-10-31 07:21:30,032 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:21:30,032 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:21:30,032 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:21:30,033 - orchestrator - INFO - Executing agents for report_id: concurrent_report_1, token_id: concurrent_token_1 +2025-10-31 07:21:30,033 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:21:30,033 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:21:30,033 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:21:30,033 - orchestrator - INFO - Executing agents for report_id: concurrent_report_2, token_id: concurrent_token_2 +2025-10-31 07:21:30,056 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:21:30,056 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:21:30,059 - api - INFO - Received data request for report_id: f657a443-37d4-4a25-bb36-e44991466a07 +2025-10-31 07:21:30,059 - services - INFO - Attempting to retrieve data for report_id: f657a443-37d4-4a25-bb36-e44991466a07 +2025-10-31 07:21:30,059 - services - INFO - Report f657a443-37d4-4a25-bb36-e44991466a07 is in status: processing, returning status only. +2025-10-31 07:21:30,059 - api - WARNING - Report f657a443-37d4-4a25-bb36-e44991466a07 is still processing. +2025-10-31 07:21:30,066 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:21:30,066 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:21:30,066 - orchestrator - INFO - Executing agents concurrently for report_id: ee0e220d-bee3-409c-bced-ddf2f72c0f4d, token_id: test_token +2025-10-31 07:21:30,066 - orchestrator - INFO - Executing agents for report_id: ee0e220d-bee3-409c-bced-ddf2f72c0f4d, token_id: test_token +2025-10-31 07:21:32,068 - orchestrator - INFO - Agent AgentOne completed for report ee0e220d-bee3-409c-bced-ddf2f72c0f4d. +2025-10-31 07:21:32,068 - orchestrator - INFO - Agent AgentTwo completed for report ee0e220d-bee3-409c-bced-ddf2f72c0f4d. +2025-10-31 07:21:32,068 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:21:32,068 - orchestrator - INFO - Report ee0e220d-bee3-409c-bced-ddf2f72c0f4d status updated to completed. +2025-10-31 07:21:32,070 - api - INFO - Received status request for report_id: ee0e220d-bee3-409c-bced-ddf2f72c0f4d +2025-10-31 07:21:32,070 - services - INFO - Retrieving status for report_id: ee0e220d-bee3-409c-bced-ddf2f72c0f4d from memory. +2025-10-31 07:21:32,071 - api - INFO - Received data request for report_id: ee0e220d-bee3-409c-bced-ddf2f72c0f4d +2025-10-31 07:21:32,071 - services - INFO - Attempting to retrieve data for report_id: ee0e220d-bee3-409c-bced-ddf2f72c0f4d +2025-10-31 07:21:32,071 - services - INFO - Report ee0e220d-bee3-409c-bced-ddf2f72c0f4d is completed, returning data. +2025-10-31 07:21:32,071 - api - INFO - Returning data for report_id: ee0e220d-bee3-409c-bced-ddf2f72c0f4d +2025-10-31 07:21:32,077 - api - INFO - Received data request for report_id: non_existent_report +2025-10-31 07:21:32,077 - services - INFO - Attempting to retrieve data for report_id: non_existent_report +2025-10-31 07:21:32,077 - services - WARNING - Report with id non_existent_report not found when attempting to retrieve data. +2025-10-31 07:21:32,077 - api - ERROR - Report with id non_existent_report not found or not completed for data request. +2025-10-31 07:22:51,523 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:22:51,523 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:22:51,533 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:22:51,533 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:22:51,533 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:22:51,533 - orchestrator - INFO - Executing agents for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:22:51,533 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_success. +2025-10-31 07:22:51,533 - orchestrator - INFO - Agent AgentTwo completed for report test_report_id_success. +2025-10-31 07:22:51,533 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:22:51,533 - orchestrator - INFO - Report test_report_id_success status updated to completed. +2025-10-31 07:22:51,537 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:22:51,537 - orchestrator - INFO - Registering agent: AgentFailing +2025-10-31 07:22:51,537 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:22:51,537 - orchestrator - INFO - Executing agents for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:22:51,537 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_failure. +2025-10-31 07:22:51,537 - orchestrator - ERROR - Agent AgentFailing failed for report test_report_id_failure +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent failed +2025-10-31 07:22:51,539 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:22:51,539 - orchestrator - WARNING - Report test_report_id_failure completed with partial success due to agent failures. +2025-10-31 07:22:51,539 - orchestrator - INFO - Report test_report_id_failure status updated to partial_success. +2025-10-31 07:22:51,541 - orchestrator - INFO - Registering agent: a +2025-10-31 07:22:51,542 - orchestrator - INFO - Registering agent: dummy_agent +2025-10-31 07:22:51,544 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:22:51,544 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:22:51,544 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:22:51,544 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 07:22:51,644 - orchestrator - INFO - Agent price_agent completed for report test_report_1. +2025-10-31 07:22:51,644 - orchestrator - INFO - Agent trend_agent completed for report test_report_1. +2025-10-31 07:22:51,644 - orchestrator - INFO - Agent volume_agent completed for report test_report_1. +2025-10-31 07:22:51,644 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:22:51,649 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:22:51,649 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:22:51,649 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:22:51,649 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 07:22:51,753 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:22:51,753 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:22:51,753 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:22:51,753 - orchestrator - INFO - Executing agents for report_id: test_report_4, token_id: test_token_4 +2025-10-31 07:22:51,753 - orchestrator - ERROR - Agent price_agent failed for report test_report_4 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/price_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Simulated processing error +2025-10-31 07:22:51,754 - orchestrator - ERROR - Agent trend_agent failed for report test_report_4 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/trend_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/price_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Simulated processing error +2025-10-31 07:22:51,755 - orchestrator - ERROR - Agent volume_agent failed for report test_report_4 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/volume_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/trend_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/price_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Simulated processing error +2025-10-31 07:22:51,756 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:22:51,781 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:22:51,781 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:22:51,781 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:22:51,781 - orchestrator - INFO - Executing agents for report_id: concurrent_report_1, token_id: concurrent_token_1 +2025-10-31 07:22:51,781 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:22:51,781 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:22:51,781 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:22:51,781 - orchestrator - INFO - Executing agents for report_id: concurrent_report_2, token_id: concurrent_token_2 +2025-10-31 07:22:51,881 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_1. +2025-10-31 07:22:51,882 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_1. +2025-10-31 07:22:51,882 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_1. +2025-10-31 07:22:51,882 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:22:51,882 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_2. +2025-10-31 07:22:51,882 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_2. +2025-10-31 07:22:51,882 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_2. +2025-10-31 07:22:51,882 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:22:51,911 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:22:51,911 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:22:51,914 - api - INFO - Received data request for report_id: e9515349-3059-42f9-b19d-a7a9bb7a91d1 +2025-10-31 07:22:51,914 - services - INFO - Attempting to retrieve data for report_id: e9515349-3059-42f9-b19d-a7a9bb7a91d1 +2025-10-31 07:22:51,914 - services - INFO - Report e9515349-3059-42f9-b19d-a7a9bb7a91d1 is in status: processing, returning status only. +2025-10-31 07:22:51,914 - api - WARNING - Report e9515349-3059-42f9-b19d-a7a9bb7a91d1 is still processing. +2025-10-31 07:22:51,920 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:22:51,920 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:22:51,921 - orchestrator - INFO - Executing agents concurrently for report_id: 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0, token_id: test_token +2025-10-31 07:22:51,921 - orchestrator - INFO - Executing agents for report_id: 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0, token_id: test_token +2025-10-31 07:22:53,923 - orchestrator - INFO - Agent AgentOne completed for report 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0. +2025-10-31 07:22:53,923 - orchestrator - INFO - Agent AgentTwo completed for report 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0. +2025-10-31 07:22:53,923 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:22:53,923 - orchestrator - INFO - Report 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0 status updated to completed. +2025-10-31 07:22:53,925 - api - INFO - Received status request for report_id: 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0 +2025-10-31 07:22:53,925 - services - INFO - Retrieving status for report_id: 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0 from memory. +2025-10-31 07:22:53,927 - api - INFO - Received data request for report_id: 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0 +2025-10-31 07:22:53,927 - services - INFO - Attempting to retrieve data for report_id: 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0 +2025-10-31 07:22:53,927 - services - INFO - Report 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0 is completed, returning data. +2025-10-31 07:22:53,927 - api - INFO - Returning data for report_id: 5b11b1b3-54b4-4f9a-b7d6-23aa2a97cbb0 +2025-10-31 07:22:53,933 - api - INFO - Received data request for report_id: non_existent_report +2025-10-31 07:22:53,934 - services - INFO - Attempting to retrieve data for report_id: non_existent_report +2025-10-31 07:22:53,934 - services - WARNING - Report with id non_existent_report not found when attempting to retrieve data. +2025-10-31 07:22:53,934 - api - ERROR - Report with id non_existent_report not found or not completed for data request. +2025-10-31 07:23:03,335 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:23:03,335 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:23:03,348 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:23:03,348 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:23:03,348 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:23:03,348 - orchestrator - INFO - Executing agents for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:23:03,348 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_success. +2025-10-31 07:23:03,348 - orchestrator - INFO - Agent AgentTwo completed for report test_report_id_success. +2025-10-31 07:23:03,348 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:03,348 - orchestrator - INFO - Report test_report_id_success status updated to completed. +2025-10-31 07:23:03,352 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:23:03,352 - orchestrator - INFO - Registering agent: AgentFailing +2025-10-31 07:23:03,352 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:23:03,352 - orchestrator - INFO - Executing agents for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:23:03,353 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_failure. +2025-10-31 07:23:03,353 - orchestrator - ERROR - Agent AgentFailing failed for report test_report_id_failure +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent failed +2025-10-31 07:23:03,355 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:03,355 - orchestrator - WARNING - Report test_report_id_failure completed with partial success due to agent failures. +2025-10-31 07:23:03,355 - orchestrator - INFO - Report test_report_id_failure status updated to partial_success. +2025-10-31 07:23:03,357 - orchestrator - INFO - Registering agent: a +2025-10-31 07:23:03,359 - orchestrator - INFO - Registering agent: dummy_agent +2025-10-31 07:23:03,361 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:03,361 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:03,361 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:03,361 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 07:23:03,461 - orchestrator - INFO - Agent price_agent completed for report test_report_1. +2025-10-31 07:23:03,462 - orchestrator - INFO - Agent trend_agent completed for report test_report_1. +2025-10-31 07:23:03,462 - orchestrator - INFO - Agent volume_agent completed for report test_report_1. +2025-10-31 07:23:03,462 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:03,467 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:03,467 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:03,467 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:03,467 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 07:23:03,572 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:03,572 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:03,572 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:03,572 - orchestrator - INFO - Executing agents for report_id: test_report_4, token_id: test_token_4 +2025-10-31 07:23:03,572 - orchestrator - ERROR - Agent price_agent failed for report test_report_4 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/price_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Simulated processing error +2025-10-31 07:23:03,573 - orchestrator - ERROR - Agent trend_agent failed for report test_report_4 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/trend_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/price_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Simulated processing error +2025-10-31 07:23:03,574 - orchestrator - ERROR - Agent volume_agent failed for report test_report_4 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/volume_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/trend_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/services/agents/price_agent.py", line 7, in run + await asyncio.sleep(0.1) # Simulate a small delay + ^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Simulated processing error +2025-10-31 07:23:03,575 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:03,612 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:03,612 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:03,612 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:03,612 - orchestrator - INFO - Executing agents for report_id: concurrent_report_1, token_id: concurrent_token_1 +2025-10-31 07:23:03,612 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:03,612 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:03,612 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:03,612 - orchestrator - INFO - Executing agents for report_id: concurrent_report_2, token_id: concurrent_token_2 +2025-10-31 07:23:03,713 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_1. +2025-10-31 07:23:03,713 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_1. +2025-10-31 07:23:03,713 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_1. +2025-10-31 07:23:03,713 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:03,713 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_2. +2025-10-31 07:23:03,713 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_2. +2025-10-31 07:23:03,713 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_2. +2025-10-31 07:23:03,713 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:03,739 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:23:03,740 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:23:03,742 - api - INFO - Received data request for report_id: 3f0b76e7-5643-4433-8842-e5c278871cfe +2025-10-31 07:23:03,742 - services - INFO - Attempting to retrieve data for report_id: 3f0b76e7-5643-4433-8842-e5c278871cfe +2025-10-31 07:23:03,742 - services - INFO - Report 3f0b76e7-5643-4433-8842-e5c278871cfe is in status: processing, returning status only. +2025-10-31 07:23:03,742 - api - WARNING - Report 3f0b76e7-5643-4433-8842-e5c278871cfe is still processing. +2025-10-31 07:23:03,749 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:23:03,749 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:23:03,750 - orchestrator - INFO - Executing agents concurrently for report_id: d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa, token_id: test_token +2025-10-31 07:23:03,750 - orchestrator - INFO - Executing agents for report_id: d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa, token_id: test_token +2025-10-31 07:23:05,751 - orchestrator - INFO - Agent AgentOne completed for report d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa. +2025-10-31 07:23:05,751 - orchestrator - INFO - Agent AgentTwo completed for report d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa. +2025-10-31 07:23:05,752 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:05,752 - orchestrator - INFO - Report d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa status updated to completed. +2025-10-31 07:23:05,753 - api - INFO - Received status request for report_id: d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa +2025-10-31 07:23:05,754 - services - INFO - Retrieving status for report_id: d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa from memory. +2025-10-31 07:23:05,755 - api - INFO - Received data request for report_id: d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa +2025-10-31 07:23:05,755 - services - INFO - Attempting to retrieve data for report_id: d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa +2025-10-31 07:23:05,755 - services - INFO - Report d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa is completed, returning data. +2025-10-31 07:23:05,755 - api - INFO - Returning data for report_id: d90f3a5d-6fbb-46cf-b88e-5cb6c70fe8fa +2025-10-31 07:23:05,761 - api - INFO - Received data request for report_id: non_existent_report +2025-10-31 07:23:05,761 - services - INFO - Attempting to retrieve data for report_id: non_existent_report +2025-10-31 07:23:05,761 - services - WARNING - Report with id non_existent_report not found when attempting to retrieve data. +2025-10-31 07:23:05,761 - api - ERROR - Report with id non_existent_report not found or not completed for data request. +2025-10-31 07:23:30,707 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:23:30,708 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:23:30,717 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:23:30,717 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:23:30,717 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:23:30,717 - orchestrator - INFO - Executing agents for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:23:30,718 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_success. +2025-10-31 07:23:30,718 - orchestrator - INFO - Agent AgentTwo completed for report test_report_id_success. +2025-10-31 07:23:30,718 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:30,718 - orchestrator - INFO - Report test_report_id_success status updated to completed. +2025-10-31 07:23:30,726 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:23:30,726 - orchestrator - INFO - Registering agent: AgentFailing +2025-10-31 07:23:30,726 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:23:30,726 - orchestrator - INFO - Executing agents for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:23:30,726 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_failure. +2025-10-31 07:23:30,726 - orchestrator - ERROR - Agent AgentFailing failed for report test_report_id_failure +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent failed +2025-10-31 07:23:30,728 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:30,728 - orchestrator - WARNING - Report test_report_id_failure completed with partial success due to agent failures. +2025-10-31 07:23:30,728 - orchestrator - INFO - Report test_report_id_failure status updated to partial_success. +2025-10-31 07:23:30,730 - orchestrator - INFO - Registering agent: a +2025-10-31 07:23:30,732 - orchestrator - INFO - Registering agent: dummy_agent +2025-10-31 07:23:30,734 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:30,734 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:30,734 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:30,734 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 07:23:30,834 - orchestrator - INFO - Agent price_agent completed for report test_report_1. +2025-10-31 07:23:30,835 - orchestrator - INFO - Agent trend_agent completed for report test_report_1. +2025-10-31 07:23:30,835 - orchestrator - INFO - Agent volume_agent completed for report test_report_1. +2025-10-31 07:23:30,835 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:30,841 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:30,841 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:30,841 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:30,841 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 07:23:30,946 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:30,946 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:30,946 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:30,951 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:30,951 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:30,951 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:30,951 - orchestrator - INFO - Executing agents for report_id: concurrent_report_1, token_id: concurrent_token_1 +2025-10-31 07:23:30,951 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:23:30,951 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:23:30,951 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:23:30,951 - orchestrator - INFO - Executing agents for report_id: concurrent_report_2, token_id: concurrent_token_2 +2025-10-31 07:23:31,052 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_1. +2025-10-31 07:23:31,052 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_1. +2025-10-31 07:23:31,052 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_1. +2025-10-31 07:23:31,052 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:31,052 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_2. +2025-10-31 07:23:31,052 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_2. +2025-10-31 07:23:31,052 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_2. +2025-10-31 07:23:31,052 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:31,077 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:23:31,077 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:23:31,080 - api - INFO - Received data request for report_id: c34a956e-9f24-419b-9574-03c0c41a91dc +2025-10-31 07:23:31,081 - services - INFO - Attempting to retrieve data for report_id: c34a956e-9f24-419b-9574-03c0c41a91dc +2025-10-31 07:23:31,081 - services - INFO - Report c34a956e-9f24-419b-9574-03c0c41a91dc is in status: processing, returning status only. +2025-10-31 07:23:31,081 - api - WARNING - Report c34a956e-9f24-419b-9574-03c0c41a91dc is still processing. +2025-10-31 07:23:31,088 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:23:31,088 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:23:31,088 - orchestrator - INFO - Executing agents concurrently for report_id: 00fdb92d-bd3f-4693-801a-cf24a106a9f1, token_id: test_token +2025-10-31 07:23:31,088 - orchestrator - INFO - Executing agents for report_id: 00fdb92d-bd3f-4693-801a-cf24a106a9f1, token_id: test_token +2025-10-31 07:23:33,090 - orchestrator - INFO - Agent AgentOne completed for report 00fdb92d-bd3f-4693-801a-cf24a106a9f1. +2025-10-31 07:23:33,090 - orchestrator - INFO - Agent AgentTwo completed for report 00fdb92d-bd3f-4693-801a-cf24a106a9f1. +2025-10-31 07:23:33,090 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:23:33,090 - orchestrator - INFO - Report 00fdb92d-bd3f-4693-801a-cf24a106a9f1 status updated to completed. +2025-10-31 07:23:33,092 - api - INFO - Received status request for report_id: 00fdb92d-bd3f-4693-801a-cf24a106a9f1 +2025-10-31 07:23:33,092 - services - INFO - Retrieving status for report_id: 00fdb92d-bd3f-4693-801a-cf24a106a9f1 from memory. +2025-10-31 07:23:33,093 - api - INFO - Received data request for report_id: 00fdb92d-bd3f-4693-801a-cf24a106a9f1 +2025-10-31 07:23:33,093 - services - INFO - Attempting to retrieve data for report_id: 00fdb92d-bd3f-4693-801a-cf24a106a9f1 +2025-10-31 07:23:33,093 - services - INFO - Report 00fdb92d-bd3f-4693-801a-cf24a106a9f1 is completed, returning data. +2025-10-31 07:23:33,093 - api - INFO - Returning data for report_id: 00fdb92d-bd3f-4693-801a-cf24a106a9f1 +2025-10-31 07:23:33,100 - api - INFO - Received data request for report_id: non_existent_report +2025-10-31 07:23:33,100 - services - INFO - Attempting to retrieve data for report_id: non_existent_report +2025-10-31 07:23:33,100 - services - WARNING - Report with id non_existent_report not found when attempting to retrieve data. +2025-10-31 07:23:33,100 - api - ERROR - Report with id non_existent_report not found or not completed for data request. +2025-10-31 07:36:55,681 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:36:55,681 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:36:55,694 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:36:55,694 - orchestrator - INFO - Registering agent: AgentTwo +2025-10-31 07:36:55,694 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:36:55,694 - orchestrator - INFO - Executing agents for report_id: test_report_id_success, token_id: test_token_id +2025-10-31 07:36:55,694 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_success. +2025-10-31 07:36:55,694 - orchestrator - INFO - Agent AgentTwo completed for report test_report_id_success. +2025-10-31 07:36:55,694 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:36:55,694 - orchestrator - INFO - Report test_report_id_success status updated to completed. +2025-10-31 07:36:55,697 - orchestrator - INFO - Registering agent: AgentOne +2025-10-31 07:36:55,697 - orchestrator - INFO - Registering agent: AgentFailing +2025-10-31 07:36:55,697 - orchestrator - INFO - Executing agents concurrently for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:36:55,697 - orchestrator - INFO - Executing agents for report_id: test_report_id_failure, token_id: test_token_id +2025-10-31 07:36:55,698 - orchestrator - INFO - Agent AgentOne completed for report test_report_id_failure. +2025-10-31 07:36:55,698 - orchestrator - ERROR - Agent AgentFailing failed for report test_report_id_failure +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent failed +2025-10-31 07:36:55,699 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:36:55,699 - orchestrator - WARNING - Report test_report_id_failure completed with partial success due to agent failures. +2025-10-31 07:36:55,699 - orchestrator - INFO - Report test_report_id_failure status updated to partial_success. +2025-10-31 07:36:55,701 - orchestrator - INFO - Registering agent: a +2025-10-31 07:36:55,703 - orchestrator - INFO - Registering agent: dummy_agent +2025-10-31 07:36:55,705 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:36:55,705 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:36:55,705 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:36:55,705 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 07:36:55,806 - orchestrator - INFO - Agent price_agent completed for report test_report_1. +2025-10-31 07:36:55,806 - orchestrator - INFO - Agent trend_agent completed for report test_report_1. +2025-10-31 07:36:55,806 - orchestrator - INFO - Agent volume_agent completed for report test_report_1. +2025-10-31 07:36:55,806 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:36:55,811 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:36:55,811 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:36:55,811 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:36:55,811 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 07:36:55,914 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:36:55,915 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:36:55,915 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:36:55,918 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:36:55,919 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:36:55,919 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:36:55,919 - orchestrator - INFO - Executing agents for report_id: concurrent_report_1, token_id: concurrent_token_1 +2025-10-31 07:36:55,919 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 07:36:55,919 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 07:36:55,919 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 07:36:55,919 - orchestrator - INFO - Executing agents for report_id: concurrent_report_2, token_id: concurrent_token_2 +2025-10-31 07:36:56,019 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_1. +2025-10-31 07:36:56,020 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_1. +2025-10-31 07:36:56,020 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_1. +2025-10-31 07:36:56,020 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:36:56,020 - orchestrator - INFO - Agent price_agent completed for report concurrent_report_2. +2025-10-31 07:36:56,020 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report_2. +2025-10-31 07:36:56,020 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report_2. +2025-10-31 07:36:56,020 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:36:56,043 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:36:56,043 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:36:56,045 - api - INFO - Received data request for report_id: 596e732e-2c77-4792-90f2-b4a2788d6c6c +2025-10-31 07:36:56,045 - services - INFO - Attempting to retrieve data for report_id: 596e732e-2c77-4792-90f2-b4a2788d6c6c +2025-10-31 07:36:56,045 - services - INFO - Report 596e732e-2c77-4792-90f2-b4a2788d6c6c is in status: processing, returning status only. +2025-10-31 07:36:56,045 - api - WARNING - Report 596e732e-2c77-4792-90f2-b4a2788d6c6c is still processing. +2025-10-31 07:36:56,051 - api - INFO - Received report generation request for token_id: test_token +2025-10-31 07:36:56,051 - services - INFO - Generating new report for token_id: test_token +2025-10-31 07:36:56,051 - orchestrator - INFO - Executing agents concurrently for report_id: c9484921-8e4a-4431-9fa0-f17e6b917564, token_id: test_token +2025-10-31 07:36:56,051 - orchestrator - INFO - Executing agents for report_id: c9484921-8e4a-4431-9fa0-f17e6b917564, token_id: test_token +2025-10-31 07:36:58,053 - orchestrator - INFO - Agent AgentOne completed for report c9484921-8e4a-4431-9fa0-f17e6b917564. +2025-10-31 07:36:58,053 - orchestrator - INFO - Agent AgentTwo completed for report c9484921-8e4a-4431-9fa0-f17e6b917564. +2025-10-31 07:36:58,053 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 07:36:58,053 - orchestrator - INFO - Report c9484921-8e4a-4431-9fa0-f17e6b917564 status updated to completed. +2025-10-31 07:36:58,054 - api - INFO - Received status request for report_id: c9484921-8e4a-4431-9fa0-f17e6b917564 +2025-10-31 07:36:58,055 - services - INFO - Retrieving status for report_id: c9484921-8e4a-4431-9fa0-f17e6b917564 from memory. +2025-10-31 07:36:58,056 - api - INFO - Received data request for report_id: c9484921-8e4a-4431-9fa0-f17e6b917564 +2025-10-31 07:36:58,056 - services - INFO - Attempting to retrieve data for report_id: c9484921-8e4a-4431-9fa0-f17e6b917564 +2025-10-31 07:36:58,056 - services - INFO - Report c9484921-8e4a-4431-9fa0-f17e6b917564 is completed, returning data. +2025-10-31 07:36:58,056 - api - INFO - Returning data for report_id: c9484921-8e4a-4431-9fa0-f17e6b917564 +2025-10-31 07:36:58,063 - api - INFO - Received data request for report_id: non_existent_report +2025-10-31 07:36:58,063 - services - INFO - Attempting to retrieve data for report_id: non_existent_report +2025-10-31 07:36:58,063 - services - WARNING - Report with id non_existent_report not found when attempting to retrieve data. +2025-10-31 07:36:58,063 - api - ERROR - Report with id non_existent_report not found or not completed for data request. +2025-10-31 08:08:41,889 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:08:41,890 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:08:41,890 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:08:41,890 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 08:08:41,890 - orchestrator - INFO - Agent price_agent completed for report test_report_1. +2025-10-31 08:08:41,890 - orchestrator - INFO - Agent trend_agent completed for report test_report_1. +2025-10-31 08:08:41,890 - orchestrator - INFO - Agent volume_agent completed for report test_report_1. +2025-10-31 08:08:41,890 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:08:41,913 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:08:41,913 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:08:41,913 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:08:41,913 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 08:08:41,914 - orchestrator - ERROR - Agent price_agent failed for report test_report_3 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent error +2025-10-31 08:08:42,014 - orchestrator - INFO - Agent trend_agent completed for report test_report_3. +2025-10-31 08:08:42,015 - orchestrator - INFO - Agent volume_agent completed for report test_report_3. +2025-10-31 08:08:42,015 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:08:42,027 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:08:42,027 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:08:42,028 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:08:42,029 - orchestrator - INFO - Executing agents for report_id: concurrent_report, token_id: concurrent_token +2025-10-31 08:08:42,031 - orchestrator - INFO - Agent price_agent completed for report concurrent_report. +2025-10-31 08:08:42,031 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report. +2025-10-31 08:08:42,031 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report. +2025-10-31 08:08:42,031 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:08:42,033 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:08:42,033 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:08:42,033 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:08:42,033 - orchestrator - INFO - Executing agents for report_id: concurrent_report, token_id: concurrent_token +2025-10-31 08:08:42,133 - orchestrator - INFO - Agent price_agent completed for report concurrent_report. +2025-10-31 08:08:42,134 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report. +2025-10-31 08:08:42,134 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report. +2025-10-31 08:08:42,134 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:09:01,740 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:09:01,740 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:09:01,740 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:09:01,740 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 08:09:01,741 - orchestrator - INFO - Agent price_agent completed for report test_report_1. +2025-10-31 08:09:01,741 - orchestrator - INFO - Agent trend_agent completed for report test_report_1. +2025-10-31 08:09:01,741 - orchestrator - INFO - Agent volume_agent completed for report test_report_1. +2025-10-31 08:09:01,741 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:09:01,747 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:09:01,748 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:09:01,748 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:09:01,748 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 08:09:01,748 - orchestrator - ERROR - Agent price_agent failed for report test_report_3 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent error +2025-10-31 08:09:01,849 - orchestrator - INFO - Agent trend_agent completed for report test_report_3. +2025-10-31 08:09:01,849 - orchestrator - INFO - Agent volume_agent completed for report test_report_3. +2025-10-31 08:09:01,849 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:09:01,888 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:09:01,893 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:09:01,893 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:09:01,893 - orchestrator - INFO - Executing agents for report_id: concurrent_report, token_id: concurrent_token +2025-10-31 08:09:01,894 - orchestrator - INFO - Agent price_agent completed for report concurrent_report. +2025-10-31 08:09:01,894 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report. +2025-10-31 08:09:01,894 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report. +2025-10-31 08:09:01,894 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:09:14,170 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:09:14,170 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:09:14,170 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:09:14,171 - orchestrator - INFO - Executing agents for report_id: test_report_1, token_id: test_token_1 +2025-10-31 08:09:14,171 - orchestrator - INFO - Agent price_agent completed for report test_report_1. +2025-10-31 08:09:14,171 - orchestrator - INFO - Agent trend_agent completed for report test_report_1. +2025-10-31 08:09:14,171 - orchestrator - INFO - Agent volume_agent completed for report test_report_1. +2025-10-31 08:09:14,171 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:09:14,175 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:09:14,175 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:09:14,175 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:09:14,176 - orchestrator - INFO - Executing agents for report_id: test_report_3, token_id: test_token_3 +2025-10-31 08:09:14,176 - orchestrator - ERROR - Agent price_agent failed for report test_report_3 +Traceback (most recent call last): + File "/home/repositories/LumintelAnalytics/ChainReport-API/backend/app/core/orchestrator.py", line 48, in execute_agents + result = await asyncio.wait_for(task, timeout=10) # Added timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/lib/python3.13/asyncio/tasks.py", line 507, in wait_for + return await fut + ^^^^^^^^^ + File "/usr/lib/python3.13/unittest/mock.py", line 2321, in _execute_mock_call + raise effect +Exception: Agent error +2025-10-31 08:09:14,186 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:09:14,187 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:09:14,187 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:09:14,187 - orchestrator - INFO - Executing agents for report_id: concurrent_report, token_id: concurrent_token +2025-10-31 08:09:14,187 - orchestrator - INFO - Agent price_agent completed for report concurrent_report. +2025-10-31 08:09:14,187 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report. +2025-10-31 08:09:14,187 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report. +2025-10-31 08:09:14,187 - orchestrator - INFO - Aggregating results from executed agents. +2025-10-31 08:09:14,188 - orchestrator - INFO - Registering agent: price_agent +2025-10-31 08:09:14,189 - orchestrator - INFO - Registering agent: trend_agent +2025-10-31 08:09:14,189 - orchestrator - INFO - Registering agent: volume_agent +2025-10-31 08:09:14,189 - orchestrator - INFO - Executing agents for report_id: concurrent_report, token_id: concurrent_token +2025-10-31 08:09:14,189 - orchestrator - INFO - Agent price_agent completed for report concurrent_report. +2025-10-31 08:09:14,290 - orchestrator - INFO - Agent trend_agent completed for report concurrent_report. +2025-10-31 08:09:14,290 - orchestrator - INFO - Agent volume_agent completed for report concurrent_report. +2025-10-31 08:09:14,290 - orchestrator - INFO - Aggregating results from executed agents. diff --git a/backend/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc b/backend/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc index 7a901e8..fc9dab2 100644 Binary files a/backend/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc and b/backend/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc differ diff --git a/backend/tests/test_report_processor.py b/backend/tests/test_report_processor.py index 735921a..e937ae2 100644 --- a/backend/tests/test_report_processor.py +++ b/backend/tests/test_report_processor.py @@ -1,14 +1,13 @@ import pytest import asyncio -from backend.app.services.report_processor import process_report, report_status, report_status_lock, get_report_status +from backend.app.services.report_processor import process_report +from backend.app.core.storage import get_report_status, set_report_status, REPORT_STORE @pytest.fixture(autouse=True) async def clear_report_status(): - async with report_status_lock: - report_status.clear() + REPORT_STORE.clear() yield - async with report_status_lock: - report_status.clear() + REPORT_STORE.clear() @pytest.mark.asyncio async def test_process_report_success(): @@ -18,25 +17,21 @@ async def test_process_report_success(): result = await process_report(report_id, token_id) assert result is True - async with report_status_lock: - assert report_status[report_id]["status"] == "completed" - assert report_status[report_id]["token_id"] == token_id + status_data = get_report_status(report_id) + assert status_data == "completed" + # Further checks can be added here to validate the content of the report data + # For example: assert REPORT_STORE[report_id]["data"] is not None + @pytest.mark.asyncio async def test_process_report_already_processing(): report_id = "test_report_2" token_id = "test_token_2" - # Start processing but don't await it to simulate concurrency - task = asyncio.create_task(process_report(report_id, token_id)) - await asyncio.sleep(0.1) # Give it a moment to set status to 'processing' + set_report_status(report_id, "processing") with pytest.raises(ValueError, match=f"Report {report_id} is already being processed"): await process_report(report_id, token_id) - - task.cancel() - with pytest.raises(asyncio.CancelledError): - await task # Await the cancelled task to ensure it raises CancelledError @pytest.mark.asyncio async def test_process_report_cancellation(): @@ -50,40 +45,33 @@ async def test_process_report_cancellation(): with pytest.raises(asyncio.CancelledError): await task - async with report_status_lock: - assert report_status[report_id]["status"] == "cancelled" + status = get_report_status(report_id) + assert status == "cancelled" @pytest.mark.asyncio -async def test_process_report_exception_handling(): +async def test_process_report_exception_handling(mocker): report_id = "test_report_4" token_id = "test_token_4" - # Temporarily modify process_report to raise an exception - original_sleep = asyncio.sleep - async def mock_sleep_raise(*args, **kwargs): - raise Exception("Simulated processing error") - asyncio.sleep = mock_sleep_raise + mocker.patch("backend.app.core.orchestrator.AIOrchestrator.execute_agents", side_effect=Exception("Simulated orchestration error")) - with pytest.raises(Exception, match="Simulated processing error"): + with pytest.raises(Exception, match="Simulated orchestration error"): await process_report(report_id, token_id) - async with report_status_lock: - assert report_status[report_id]["status"] == "failed" - - asyncio.sleep = original_sleep # Restore original sleep + status = get_report_status(report_id) + assert status == "failed" @pytest.mark.asyncio async def test_get_report_status(): report_id = "test_report_5" token_id = "test_token_5" - async with report_status_lock: - report_status[report_id] = {"status": "initial", "token_id": token_id} + set_report_status(report_id, "initial") - status = await get_report_status(report_id) - assert status == {"status": "initial", "token_id": token_id} + status = get_report_status(report_id) + assert status == "initial" - status = await get_report_status("non_existent_report") + status = get_report_status("non_existent_report") assert status is None @pytest.mark.asyncio @@ -98,8 +86,7 @@ async def test_concurrent_different_reports(): await asyncio.gather(task1, task2) - async with report_status_lock: - assert report_status[report_id_1]["status"] == "completed" - assert report_status[report_id_2]["status"] == "completed" - assert report_status[report_id_1]["token_id"] == token_id_1 - assert report_status[report_id_2]["token_id"] == token_id_2 + status1 = get_report_status(report_id_1) + status2 = get_report_status(report_id_2) + assert status1 == "completed" + assert status2 == "completed"