From 72b7d6c43c6a4c9ab612ebba7b56aaab4b37c9ca Mon Sep 17 00:00:00 2001 From: Lance Herman Date: Fri, 31 Oct 2025 01:23:37 +0000 Subject: [PATCH 1/4] Integrate AI orchestrator into report processing --- .../api/v1/__pycache__/routes.cpython-313.pyc | Bin 5049 -> 5049 bytes .../core/__pycache__/logger.cpython-313.pyc | Bin 2518 -> 2518 bytes .../__pycache__/orchestrator.cpython-313.pyc | Bin 6720 -> 6720 bytes .../core/__pycache__/storage.cpython-313.pyc | Bin 0 -> 1179 bytes ...ort_processor.cpython-313-pytest-8.4.2.pyc | Bin 0 -> 2924 bytes .../report_processor.cpython-313.pyc | Bin 3335 -> 2621 bytes .../report_service.cpython-313.pyc | Bin 3046 -> 3046 bytes .../__pycache__/__init__.cpython-313.pyc | Bin 189 -> 189 bytes .../__pycache__/price_agent.cpython-313.pyc | Bin 0 -> 598 bytes .../__pycache__/trend_agent.cpython-313.pyc | Bin 0 -> 618 bytes .../__pycache__/volume_agent.cpython-313.pyc | Bin 565 -> 601 bytes backend/app/services/agents/price_agent.py | 4 +- backend/app/services/agents/trend_agent.py | 4 +- backend/app/services/agents/volume_agent.py | 4 +- backend/app/services/report_processor.py | 59 +- backend/logs/app.log | 541 ++++++++++++++++++ ...ort_processor.cpython-313-pytest-8.4.2.pyc | Bin 12353 -> 9073 bytes backend/tests/test_report_processor.py | 63 +- 18 files changed, 599 insertions(+), 76 deletions(-) create mode 100644 backend/app/core/__pycache__/storage.cpython-313.pyc create mode 100644 backend/app/services/__pycache__/report_processor.cpython-313-pytest-8.4.2.pyc create mode 100644 backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc create mode 100644 backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc diff --git a/backend/app/api/v1/__pycache__/routes.cpython-313.pyc b/backend/app/api/v1/__pycache__/routes.cpython-313.pyc index 42d0ba289de6a6e1f39b36a6bf4bb20362db5e15..e01f4d2a9344d8511420d3440be2e794dfac490d 100644 GIT binary patch delta 20 acmdm~zEhq1GcPX}0}#~xW!}iWP8a|`jRoES delta 20 acmdm~zEhq1GcPX}0}v!`XWYoWP8a|^6a{$z diff --git a/backend/app/core/__pycache__/logger.cpython-313.pyc b/backend/app/core/__pycache__/logger.cpython-313.pyc index 70511bfaeac2368679a833f6bb0e71c5c3d57058..56d8e37a584fac1d96771b21b5f53dca315eeb5a 100644 GIT binary patch delta 20 acmca6d`+19GcPX}0}#~xW!}hrniBv)I|c&) delta 20 acmca6d`+19GcPX}0}vE$XWYnrniBv&G6k*x diff --git a/backend/app/core/__pycache__/orchestrator.cpython-313.pyc b/backend/app/core/__pycache__/orchestrator.cpython-313.pyc index 02c610a2826aebc839844d18f37672a6776147b1..10941091510d84699f7b5b199b25c36cb3ccb3c9 100644 GIT binary patch delta 20 acmX?La=?W9GcPX}0}#~xW!}hbDg^*RfCZEQ delta 20 acmX?La=?W9GcPX}0}v!`XWYnbDg^*P2L&$x 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 0000000000000000000000000000000000000000..f5811946c1ead2fa0af4c2887c9790f5769ae3fe GIT binary patch literal 1179 zcmaJ=K}#D!6rR~^HfuLltYLd_Mbi$h}67@+EO0wKWT5|2q-+f)HbNF<(D zEj{d^q#RJb<>x|;ahF$^2W2l;3_P)0ufZImEP8txdWsQpdlAY)1CEkXt|D190k`rv zi?3s%dnXn}EOmdxA)J|fmzYsmGuSa*GwLR_T34tj8>%^%yV9-WFqv6gU(0N4IU8%4 zMN6TgQ5j>xGtF?_-VKVx7D<@T1L_lIuT+YDiIc)Y$t~=0-(&X6UDq#V7(bn!`L@v* zd+{mx`OT3&dN%b~cny8DsvqfA3+|#&ql8yzY1ISjE|oe* z2Ui3`Y#z*Yb)>(KH^!Da>X=M*)S)%>iPNe1&Z7{EB+b&=gJGOX%~6pSehA;=R8*;> zh+H`*{aG={RSM)ey$>NVK(+*?8N(Q#^$i>(n`#`-R0o>~j+%ENj^7fK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?8F^8@5>qXho@Bs6$f_)-|~ z_`VWB`gYHNPyCVV?s|j)ulKIl&gG7NJg^JhJ1q=g@4a{WJn)l9DS_H3FpUkUoMi<^aOMvTaa-UK5L>N2#*o^ z6kU)0f})Sm@keOb`i(wDXP*S(%YpU>f%duMOM%_jd}~s#5S>4>hM>89*lO+^`Gfc9 HaWM7|Iam9i literal 0 HcmV?d00001 diff --git a/backend/app/services/__pycache__/report_processor.cpython-313.pyc b/backend/app/services/__pycache__/report_processor.cpython-313.pyc index a0ecef5301b34a3c99253267bb6cac0e68e445b5..fd644e8c8d74bb274123989ff4a6ded318fa5ed3 100644 GIT binary patch literal 2621 zcma)8%}*Og6rc63?eW)Q5=Q|_VJRTTq%lef4WN?BBB;es65&u$naW!1vDwDnwPx2S zpdQi>sp+XzrAQn(rnek=$hArS0H`g2wnUB8Tymo#l`6G|zFF^jowh+;*`D{_ym{|8 z?`wS=i3AZm^}L`w^&|8vW1Pol6UW~HaTjG!hMPyUxpI^P-ZSq>^OTpEjGq_MUh1=H zKhW5w13(8YT9^-|!!(?Z&`4UOqJ&ntr9Q`ZyzmzW&wImwXxA zgFX>xti&Y(&zZ_%f-}X`+%=kCC%QppL!%(!X-!S=W>l9qNRE=KMvYuSHe|C?Cx#=? z4cVyaW@qVNqJVuwDVW&MZW1*Il#ddlM%BE>MT)#Ye*xd)FF`tpB#2YiMvl-ja&D2~ zrdAM=I}pn9&gqP28Ho_LG2YQ4T$b6ho@I#kxa~O7>_SApso^hn^3fS#?&Y=umhkI;rclkwc z7^yrUIqPaV)N(6gs*vq=q$`4B2jbNp$3UC>1Z7(l4!Q}1RPRgZBCc**mIqu94wVtx(Jgxkm%*wxAr7fL5kNE^JC`1Z+DFusu)bi++qt((5GRw@x{3W^E<*^n?rN=k|jk+KnWv|-J` z+%!Ad@LGasJ7!BFl3OHSGwf@?43$eIFbf3)!&R@94V|(UH2t!^spb{U6la`UShZjV zTIn?dt$ZeY6vHXXW}F$;+D5t=u|nw>H)9Z?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+M!Qc>glzXLQH|!!bW)42W%==Yc%(C4%UAJS zUQd^E=#`vEo2;aY@rY))cj?{kr%!YLAs<0D8&Eczo?E@X}&-{Ak pH?LPv%Z~dP4lWJvAn0zMvbvA@AF#ij3C!aYOU5S%IvNGdUjPpM*n|K8 diff --git a/backend/app/services/__pycache__/report_service.cpython-313.pyc b/backend/app/services/__pycache__/report_service.cpython-313.pyc index 904f91a30d70a211872920f2ee9cec9b449e7875..b04c106b1ae57da98f59c0fdce628f43b9f90049 100644 GIT binary patch delta 20 acmaDR{!En#i>o055h03;+NC delta 18 YcmdnXxR;UZGcPX}0}w@G8#Ks<@P z_0m(Jir(v=;Qydd@t~~UJoOfd9=!Qxjo=3}@5g-e-p8An)@mLg_9CVT0r+l%e_%6b zdJ&yN2q7d}pdoa2NJw|cH5RgEc*?XB6W=|xnP1)1Dp3Kz=#~umb-wrL;CPc$eQ#DRG?M8LAxmB zS<}0hM!SZ0WghiZ67x)}Nb-)z1@ESs3m&VHOn51<>BX;JTD-g6ia)$Ze0zMyr-fTy z(pIm=mf$lQOP)RQPYl-NO za}}9jy(d(%T~4a8c7G#yA|f1BClFZ{7^z37)&wG!Np6BtM!O7}*|?y3m}vWER+I5@ zJB8=)vjX!=2aWy45&h)VKePG?tA9DSa(w>d{N@SU{6WFJ@Y^gP`^EAqc}=deH{L4o zsh-1BK~1j9nr~r>G3ctzR&EZ`&af|U=|v3f3mE$mCX^8J6&5GVC0pd^>;$YmroT$7 HYe@M6`3jLh literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..b417d646a410e527026d38c5837aecd1e9e94b70 GIT binary patch literal 618 zcmYjP&1(}u6o0cbtLdiIVyj?@vZx@7Bnwi}gQ&%WlxmPJh+rgaHOuP%noS49?l1LgI$0MG@Yxo zOS~gn4d-4OZECm6^C%HAc5}sL$L)l9=yp@(hHfl|T)HL2h7-SeZSe7Cv#8H+*^;914dP>*CJ(!$m~&NI&{56Td2?&7*d+fULy z_sv|i$WtY__U{h*Lgu`;BE#M&7m@aFC!vt*A&k9seysE#f@6b<9?K7+Gv)Y%Fr*{`WTsx?? z_F3x(1^dizZ4#d?dE_m*$lg^w;!!n&u7c`Zl~v!v1Z_}Nopr=3BM-%#^tnpe^0 dbBrk=($e79y%n;1z%}~S;%oM{I%pAjL z!V=6P#gN5P#FWmc$@&tc*zXo+QEEYcQAvDe$}NtP{Or^`AS;;(Y7mG58QKiQpF@De z!~z$#2!UW0J?4qK0?nCkv6bcLl;)-uffN-n0|`y0TkMI&m3hgT`L|e$b5c_aG?~B> zU?s&MgB2#5GiEY!O0078nK-d5P delta 285 zcmcb~vX!O&GcPX}0}uoo?(vLwL7+``jK1%@^QyGF8f*HLTiWq{KVi--Bf|;cl zvRI0k(it^bUV;?*-Qp<8&rZ#Y&rC^Xgz5xQ%s|`>#GgZegffEy(4=S}3k)XqnX-j4 z1heQdO*|Q>!*q+SEI+3-H?;_)N0aFmdtz~AUUFvsE!N_k)YJk^MzBON$n?p9jG2s_ zlXo*}vzT3AF`N8~QOcVQD1M8%xTL6v6UbW0@EJ%l6mft=Ic#$CQ%ZAE?TUDTT#y09 eB0%B;Gb1D8Z3ey%EUb*?Gnl_J0I4D#pacLeOF3Ww 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..a610a0b 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, get_report_status 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,32 @@ 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) + # Check if report is already processing using the storage module + if get_report_status(report_id) == "processing": + raise ValueError(f"Report {report_id} is already being processed") + + set_report_status(report_id, "processing") + 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" + except Exception as e: + set_report_status(report_id, "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 + raise e \ No newline at end of file diff --git a/backend/logs/app.log b/backend/logs/app.log index e300685..b476efe 100644 --- a/backend/logs/app.log +++ b/backend/logs/app.log @@ -53,3 +53,544 @@ 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. 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 7a901e80a6c231c79196860e7cd120753a5cc830..339181e9155d6bb5417288fa7cee7c4d9c9635c1 100644 GIT binary patch literal 9073 zcmeHMT}&L;6~41G`~QOhV;kGRUVhp19_S(A0Au3{-jRo-x1sdAKuo_lBR%hI!uX|$q*(BEU0FngB z{X8dm_M(2H8P@@=Xwk4zEW%3GQ}WvQ>bJq?v+*@-gU@f{YupB3z{a<88+<_l#(_A$C6%pEal+z+}IG<8fHHnqEJT63et$tc57`3EYkPGvwRXMR6cNY}3pwgVl#}Hl~cg-zmjdUv3rHc-SVOp{f zRfOy-w1_r@9Tj2Mny~A(u;;GezssuY!k&jJId4lnN4Y8?dZFZYW@w7}Sjl=?ukScCruS9NLSe?DC8Yx>?&>%8z}6=3s^SV&bJTL3 z2e7d1#F?6Bb4cDU*Adu3&Mo;Qf86~nM{Ax$9h=2A)(+NYJz>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a*X|)oS0 zr^+(v$$43}44PPnT4gKL&moj!>@36BsTnZ!uvFKK+iJGg4q#E;#yNsmhunfPma%13 zb%y;VfnJrLiDyqiAOj)c>2Y1T*z^kfRFAp)4-cKjUf4=H9yvd9uUz4M*hy=9zwP7dg1cpfYgyu2tj+sqJ`ldTi|(@zUjOEj z2uVILxFYJmWpR*hwqy3TjV>Ug$z>8yj6voX*XZti0D?k8KdZ|JhE_!Vw=51V1$wmX zZ5wSeK;h5o%v`=GXBHR4A+zr<_A!rKX2|>tC*#}+Ujt59!jB$1Ky&NDKbYFAAL$NqqLI&avPkzFt3J`p-g0{&bE}%1XyR_w@JKfjOq*!h%%3I}X&AFpcj#wT z+v0O`ZE(uyOcD;LKm+tNjd@yC3%Fq3UTFN7%abh+98S{skYyZ=t4OW-8HaeO{@e8{WK*7Odf;%8euCB2tCU== zDXI67pk58sYGX;Qmkb!vNUk=N)K`#ZT^gv>?IpDyQm5AfwOUtF8z944+YcN_(y{no Ddkc#X 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" From 54a7a6cfe204685f0c32436e9095475e21de7772 Mon Sep 17 00:00:00 2001 From: Lance Herman Date: Fri, 31 Oct 2025 01:37:02 +0000 Subject: [PATCH 2/4] Fix: Preserve full exception traceback in report processing --- .../report_processor.cpython-313.pyc | Bin 2621 -> 2617 bytes .../__pycache__/price_agent.cpython-313.pyc | Bin 598 -> 598 bytes .../__pycache__/trend_agent.cpython-313.pyc | Bin 618 -> 618 bytes .../__pycache__/volume_agent.cpython-313.pyc | Bin 601 -> 601 bytes backend/app/services/report_processor.py | 2 +- backend/logs/app.log | 86 ++++++++++++++++++ ...ort_processor.cpython-313-pytest-8.4.2.pyc | Bin 9073 -> 9073 bytes 7 files changed, 87 insertions(+), 1 deletion(-) diff --git a/backend/app/services/__pycache__/report_processor.cpython-313.pyc b/backend/app/services/__pycache__/report_processor.cpython-313.pyc index fd644e8c8d74bb274123989ff4a6ded318fa5ed3..302e80bdeb78069c6ea3b30667519bb539745fe6 100644 GIT binary patch delta 151 zcmdlhvQvcjGcPX}0}ybgvt-`e$ZN~U*tFT3QH_aFV{#F*2U9A;=6%f5nHeP}hp~Gw z@=c!4z6MD8aL5RA@c#b5&dkd9r`Qgty~&Z$#eQ-vhlGNQJ>y{wMrSRC!&+J{Hq1vv tlwHi3kC?N9*fz{A_M5kIKF!>7N6&V7J0sw&WCaC}b delta 174 zcmdlfvR8!nGcPX}0}xzJX32c8k=K@yv1PM2qZ$*V=Hwz~50+5YRL0GFn5Q!{N=*)7 z_h1y5JePe9ko4k^@#W+1VE_GrotahOPq7`)h$cryR|dv|ERG7!S`3F&7@aj(4yiga z0Xc`&K{AIm7(r|;Ef-tnBO)p;7R*O1SV3%CW><#I8#!_rr3Dr^e_&8&6xd)4rgoTo L1@Vdufu;ihVCyUn diff --git a/backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc b/backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc index 0b4818182550bb41eec75c926a418962f823ea4f..b5d848bb8584a072be98be3cd70cfdfc9307b85a 100644 GIT binary patch delta 19 Zcmcb{a*c)SGcPX}0}%X4+sNg^1OPdx1wjA+ delta 19 Zcmcb{a*c)SGcPX}0}wPPZ{+e}0suC{1jPUV diff --git a/backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc b/backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc index b417d646a410e527026d38c5837aecd1e9e94b70..8a9f98418f60b9b462b64ea27965edee44fb979a 100644 GIT binary patch delta 19 ZcmaFG@`{D)GcPX}0}%X4+sKu`1OPms1$_Vj delta 19 ZcmaFG@`{D)GcPX}0}!+)Z{$i~0suMF1qA>A 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 a695833ef85c0a5a4b69209b88c1be201ffe372d..fdc760093eb876e8ecef0959068f31b754492a86 100644 GIT binary patch delta 19 Zcmcb~a+8JYGcPX}0}%X4+sNh51OPf31xf$_ delta 19 Zcmcb~a+8JYGcPX}0}vcf-pJ+81OPbA1rh)N diff --git a/backend/app/services/report_processor.py b/backend/app/services/report_processor.py index a610a0b..d12421e 100644 --- a/backend/app/services/report_processor.py +++ b/backend/app/services/report_processor.py @@ -49,4 +49,4 @@ async def process_report(report_id: str, token_id: str) -> bool: except Exception as e: set_report_status(report_id, "failed") logger.exception("Report %s failed.", report_id) - raise e \ No newline at end of file + raise \ No newline at end of file diff --git a/backend/logs/app.log b/backend/logs/app.log index b476efe..73a962b 100644 --- a/backend/logs/app.log +++ b/backend/logs/app.log @@ -594,3 +594,89 @@ Exception: Agent failed 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. 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 339181e9155d6bb5417288fa7cee7c4d9c9635c1..fc9dab20d428a29c41eb5379ed3869b3771420b6 100644 GIT binary patch delta 19 Zcmez9_R)>&GcPX}0}%X4+sKu!3;;%t1~&iz delta 19 Zcmez9_R)>&GcPX}0}$L#-pG}%3;;#a1{VMT From d0f40b421de497bb663c0a098dceddbc0a928004 Mon Sep 17 00:00:00 2001 From: Lance Herman Date: Fri, 31 Oct 2025 01:51:06 +0000 Subject: [PATCH 3/4] Fix TOCTOU race in report processing with atomic check-and-set --- .../core/__pycache__/storage.cpython-313.pyc | Bin 1179 -> 2222 bytes backend/app/core/storage.py | 40 +++++-- .../report_processor.cpython-313.pyc | Bin 2617 -> 2753 bytes .../__pycache__/price_agent.cpython-313.pyc | Bin 598 -> 598 bytes .../__pycache__/trend_agent.cpython-313.pyc | Bin 618 -> 618 bytes .../__pycache__/volume_agent.cpython-313.pyc | Bin 601 -> 601 bytes backend/app/services/report_processor.py | 11 +- ...ort_processor.cpython-313-pytest-8.4.2.pyc | Bin 0 -> 17372 bytes backend/app/tests/test_report_processor.py | 108 ++++++++++++++++++ 9 files changed, 143 insertions(+), 16 deletions(-) create mode 100644 backend/app/tests/__pycache__/test_report_processor.cpython-313-pytest-8.4.2.pyc create mode 100644 backend/app/tests/test_report_processor.py diff --git a/backend/app/core/__pycache__/storage.cpython-313.pyc b/backend/app/core/__pycache__/storage.cpython-313.pyc index f5811946c1ead2fa0af4c2887c9790f5769ae3fe..07e580c9c6eb9d5753055f8ffc5550453858fb6a 100644 GIT binary patch literal 2222 zcmcIlO-vg{6rTODjn@Vn0t$^0Oo0SQjZF|gQA4U)RcN9hKwdahK|!1KVit_onpro6 z6E~!`>Y-{>4n0^^5B9Bxs_HSh^%%!hu~s=CMXJ=BRcMiV>YK5RUF34>uJ+CBn>RB% z?|a|3C++PDf-ABmo4>dadc$7o7rgW9WFMMmNJXmf5D_$ih_Hs@a&@rT4x;JWE0I)j zO;)8fc}iC0YiLU*F79!GR~Yvo1b#R7yK8grf zfmuubRiW9(vY|?B1mfYIuC0VoQg|DM(P(X_1gyIuVl)8zv9Y_-0NN17?}t&tsNuEW>OR8nFft6WOvN8ZKPspEwyW#I*op?shR0GPvv-Q`9buF zrf(bRL{!UUqB?9AWm{@VBa+#5I;mkdzJ#Tm_+c+V5z$#N`{*}ssO;#}hNGSM(3%?ic;zXI`ZA9eG2)dP9FxFU&m{o|1l0Vxq@!6T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+b&=gJGOX%~6pSehA;=R8*;> zh+H`*{aG={RSM)ey$>NVK(+*?8N(Q#^$i>(n`#`-R0o>~j+%ENj^ 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.pyc b/backend/app/services/__pycache__/report_processor.cpython-313.pyc index 302e80bdeb78069c6ea3b30667519bb539745fe6..2e803ef9d4c7ef900aaaf14af3a2d3d09ea0ad1b 100644 GIT binary patch delta 759 zcmYjNOK1~O6umE#napIIDb#-QY3qcL+EH60>4%D;jUix*8xtadEJ84oFc>p&CKb|! z6-X zcD4Okm`7U-iC&R+x@!aQg9L9O-RbCBoU*(=CSd`cM>7}6TmT?#w>shu%j;tTktxF8 zF$vP#xd)K2O(j8u1QntzQUwiC?R-H2ai7>Vsw57`H8(e-Yr zwp_d3n7!9X2PLVuce2 zMT=)fh^&1X8H;()zB?jCSD?O(qG5aecEm=4gFA>+4#KG8uS8t2aq9axMN;ypK8e4w z8RWua+$`fJEanXMaueb+t+??-$&izjD!K<7+{ejjB-WxQK;ToT3%m1wJCS~ijQt1s CDVj(C delta 673 zcmX>ox>JPrGcPX}0}ybgvt-`e$ZNt_&kE!<1M%l3CI$v&1_g$x4AG1rB_I&WUECjTS2ca*OAzBWmlAR$@gMlHB z6~$q^2(?HKQ-tY3(7}AbAb@)!l_8iTkJXVijWLbEmRX)*6N@<`&n>QkqWt94;^NG_ z^vM~l^Br%or6p$Oq^48}2Bj9{7nLZe7ArtR^fU#F*nx)M;tEU5DNS`PD#|Y^0tL)1 zww(O*^wgqTESY&}`I8IT3MW5jGhk$!EWvKed5bZ%7^FyHauj==xdbpmUNST=e34<` zkenfTnO%87&1H7uJA4u|%okWL(7vGSaY54aGN0E44zDLHq7yO~$XsF3yE9pW<4~65 z49x`*S2* bool: """ - # Check if report is already processing using the storage module - if get_report_status(report_id) == "processing": + if not storage.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") - set_report_status(report_id, "processing") logger.info("Processing report %s for token %s", report_id, token_id) try: orchestrator = AIOrchestrator() @@ -46,7 +45,7 @@ async def process_report(report_id: str, token_id: str) -> bool: except asyncio.CancelledError: set_report_status(report_id, "cancelled") raise - except Exception as e: - set_report_status(report_id, "failed") - logger.exception("Report %s failed.", report_id) + except Exception: + logger.exception("Error processing report %s for token %s", report_id, token_id) + storage.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 0000000000000000000000000000000000000000..49596ee45453455f6bd8525a6da028655d813dbf GIT binary patch literal 17372 zcmeG^U2GiHdNaGT|NnMu$4+8zf{n6-_}@+($4Lw%fj}I(;|&Q0mc<_13-+!#vj!Z5 z6qQOhpj(m$kn(UJB2{XWwhw-!eG3mf6=^rNu{HH=shaAFhg$`FB`WjM?>jSd&g^=e zjeA>NRpey-&H4Gx-#2HzpL4#GjZnxhKzQWB;HB;tzeC2r!TB_85|r{hKMIUn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Nb|#3G{{-b#$kGk0b*aL_si(06z Date: Fri, 31 Oct 2025 02:09:16 +0000 Subject: [PATCH 4/4] Fix imports and async calls in report processor and its tests. --- .../__pycache__/orchestrator.cpython-313.pyc | Bin 6720 -> 6946 bytes .../core/__pycache__/storage.cpython-313.pyc | Bin 2222 -> 2222 bytes backend/app/core/orchestrator.py | 7 +- .../report_processor.cpython-313.pyc | Bin 2753 -> 2678 bytes .../__pycache__/price_agent.cpython-313.pyc | Bin 598 -> 598 bytes .../__pycache__/trend_agent.cpython-313.pyc | Bin 618 -> 618 bytes .../__pycache__/volume_agent.cpython-313.pyc | Bin 601 -> 601 bytes backend/app/services/report_processor.py | 6 +- ...ort_processor.cpython-313-pytest-8.4.2.pyc | Bin 17372 -> 18130 bytes backend/app/tests/test_report_processor.py | 40 +++--- backend/logs/app.log | 115 ++++++++++++++++++ 11 files changed, 146 insertions(+), 22 deletions(-) diff --git a/backend/app/core/__pycache__/orchestrator.cpython-313.pyc b/backend/app/core/__pycache__/orchestrator.cpython-313.pyc index 10941091510d84699f7b5b199b25c36cb3ccb3c9..bc867f68261c1b4d338420e2fae13ce9dbeea377 100644 GIT binary patch delta 865 zcmZ9K+iMd+6vk&ZySbUoZj-i28`FedlU}s+A~lI(O{}#stt7_!AT4Q|Mxjm0BoPrW zAU^cT3-jWm2x5Gxm4H<6A-y~lL@;P=j0pY-DJfo1#51YBIIzF-o$s7IGdpaq@6jQB zSroMh){{7YY1{Z*|5(M{;3%&0X1}Z6W86jGXo5JJZP%XT6k4&C-qsCi%t$sZ>VK4N z^quaQLIJKxwB5Wf7UY_rB^Bhql0g`G%jG+QUpc)h!MU} z9DF7|6_=#Eu6c2!AXy#^=cSg6WlQQ?sm*z|4v!UN+qT@Ams=lRTOP`{xj)FB9RWE9 zN=hW#-l`ku3w;WopdC`eTP2t>(p`dOOC{;Xf_RNw%;Vw}R`^po*AZPXi-m0KF8v(*Il`&ivz zCxh@YPUYUEXh0M82a<7y;{e)P6T@e+cWSIS6o7oxsU;^_ahTy0!w7?)VSs^WVAn-1 zFq~#!Z;}QE1H;%q`04Lj4<5_9O_#Bu;x@995#Z#=1YI|G2oXqPv}|5#XAMPuDv_8Y i%=~X^QSF&e%%ta{N69RGT{o|UkT`ldf+3C|7y delta 706 zcmZ9JO>7cD6vt;47Ff!%K>1c^BQ@cu(y=KuclpEobN&*ocm#-S+c z39S3SRJT4@UK_Wx+$P5o)ZhH1{Yq(&y%*NUCP<2G2oYheMVgcPOPpE|^Ll5g3POCYz$Ha*TkHsGY9;=_#E71I5XqlsL<)~J(bJPv8O`K7QYddLF)U;hQ zpm(VO{9TcvmV&V*zC%^ubkqWBaXJ>_J98RzLOeQ4c&db;d5**R|1K5mDxxN2xWH!l zY1R`B`V@DO&eAC&tJn==AkY^x#ll7{trV*DQmra;iViL*5&-le)Y!I)ZP~sttXag$ z#}=i-dh_H{M^BP_I+;C@YV-`Vn94~L?`Y%(1h(zeXlq^Q`nuKb%+B>abO%!c?{8Qe zxmPC}H=lb41j_ALYrK_fIo~9|W2t!YSsNht$ZTU@OlvgW44MNfy2{elEL~@9>pi0q zfdI^S9K#WI*`~k*?`+-^eNDZR&(sRC=3ssS1Nd7#0p{o0UwkoJmM 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/services/__pycache__/report_processor.cpython-313.pyc b/backend/app/services/__pycache__/report_processor.cpython-313.pyc index 2e803ef9d4c7ef900aaaf14af3a2d3d09ea0ad1b..23343ce4a863669829672e2566670524854f5adb 100644 GIT binary patch delta 645 zcmX>o`b~uQGcPX}0}vSJv1Fc|$ooTBsHCVezBsiczMv>SIkmVrGcSFzIHNJo1SSRs zWd;R?sSMGKld~A*xq*BL2x6T)g;7zH9mWr43T5D92xc~BHf4l}r7}h%tG>smT+azp zZ3<=NF@-V(al=FrbTDf)4~%CDHAR5|hg!C1KH}6)ZeU^+7r?4kc=8-3Lq^fb=a}Rz z#bGKUSP*tcOTt7$8G<>H#F71|#;nOL1ydI!GdYS`+8kLQ4?BNx$l?X!VkuxSzhr1&_#(x?BR3=SI=99} zZjH&G*?;&-&d^*CafL(g1_$p4c4k(-KgGsC4NZUFYl)?J-w;|@WQleOftoFEx1cxc z&7%z7dsGk+dJ%eRiyt5$M1pwtq!N)H1by4~8S239o0uLH!k+IQco-GR$i@t)NX## zjPEKNOZ^UOqWD=oyILRz`MSNb42QSK%93(;yG})Lv`B<6c-+@86mQ@&v8F9P a3O2Sk{X6^y7L#Sg?SYH;lGl`~Q2zoq&3`5U diff --git a/backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc b/backend/app/services/agents/__pycache__/price_agent.cpython-313.pyc index 58f044e7e4e6379169f1ec798a2e0300d0f54523..121024fa98320692d83f46bd2f939295831bf7e5 100644 GIT binary patch delta 19 Zcmcb{a*c)SGcPX}0}x2(ZRGM{0su6M1ZV&N delta 19 Zcmcb{a*c)SGcPX}0}x!#+{op_1OPbM1s?za diff --git a/backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc b/backend/app/services/agents/__pycache__/trend_agent.cpython-313.pyc index cfb6cffe9e7c06ea43838027bb772bd6626e8f1d..e408fe73831676fdfd5aa8860fa38e10f9233803 100644 GIT binary patch delta 19 ZcmaFG@`{D)GcPX}0}x2(ZRAQ|0suFH1f&1} delta 19 ZcmaFG@`{D)GcPX}0}x!#+{l%{1OPkH1zP|B 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 49eb1e17ccc9900822a08dc388d27a93c224d5ef..e54d721c39388e97c544fa2ffd1ebd974543dbe8 100644 GIT binary patch delta 19 Zcmcb~a+8JYGcPX}0}x2(ZRGN20su7p1aSZW delta 19 Zcmcb~a+8JYGcPX}0}x!#+{oq61OPcp1t bool: """ - if not storage.try_set_processing(report_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") @@ -47,5 +47,5 @@ async def process_report(report_id: str, token_id: str) -> bool: raise except Exception: logger.exception("Error processing report %s for token %s", report_id, token_id) - storage.set_report_status(report_id, "failed") + 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 index 49596ee45453455f6bd8525a6da028655d813dbf..abaad7ea60ba9716fa8125adfd7a1f3ed6fa9d2f 100644 GIT binary patch delta 3506 zcmb7HYitzP6~1?7cjvJ?yW{oldi`D-6Z{CxNFmf zNQFSuG*u%CSFLCjrToZ`IzI}H`y*9awI-7DqlK<(gXzXfsDxC}AC(EMXlc~;oLOTm z2a)tj`^~xMeD`(coO5TFU!#9~gE}8*no6L3d(1Li<-Xwb3oZ0QVQ4FDlbLJ~LugZW zt4s|Lki|CpZU=LivZYPi?PSgXIb=JK!(Z`vFL1X@hfY4umTY{bAS=s|Ge~$$LsOtzG!=6Ey*Kh#(3=J^Na02>&9xta<;gV45I0wr;sFMiUL;}1~=^2c6}KuE+X#L>CPUNqHCe;+ROtN%{jZVs-F&p_Dqf zMXXHII^{BIIJ<_*gs>$^He5YU@Iwy&IIQs%-NMg_jJo(8OCHbMu8R7aHH90NBUCpn zpA;(aEYVVe)~z-|#uUSCq;kLYWxEIWGiL9!8(#jFwO-OXov@;h|IOB~r3D3(?K1pE zIzJ?JDj6o*VaWWdt>O!~nX6p&3%LjQdvd8wCaq#b=d;zBG@rj;ohOylin-({<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SN<~cNaU2$2)=o{98w5Oz2 zyfg9E#Lf2Q!Bw@RWT{?iFIWy>?Q}j8plsMk%`ZCO;H;hZ)Q(ME1t$oVgg3XiufL7| z+|pk!te7Ma@6;>(5&2G7m)n#9LCj72z7+gV-#2D*9HD$#Y`D&E{@0^{1HMSbqnP?~c=a!=LZY(o>h}@JP{wka%pB7ndw-4-H z-Cn?x-M)Hdh&q5pT>v3M_oM7Ya3kREXeC?j-s2G{E>$kx6Cf4&OqSA@+26YxP5Ml^qZC-j<(Et~xH3+|_ySnf#^sRW~i|s?GZ+^0VpHUGt@? zy&o*xYA957LJd|^>}r)6MCT>)P~y~@rTITt0&fmOC4zNr*F1JNV63?*O2ArkT>RHJ z3TJ00dYiAFhvly;eS~}496QJ_nPYz8=W5I<-jYE2wFJ5qP6hLdRf*M@SE@u%ulSYN zet9J%qV=E>>lRl!MBv;eN?$8~+wAHK^0(^=Vo*g*3jzEZOD#l-rtB1j-vqr3Q+gH4 zEJR*&1{=}~2Sb@aG#WrL63WndG#RK5d2lJ*Yu2euCPA}0p%n-LP=2jOJ&zup ztg){)x?}%Eb05NU2uBh65%i5?qFa58{iN@Na2@6Yxl&)RLG=`+SFa>zv&mEj8h+?# zq`V=$K`yY_qcZ`D|4@pponmvN_|_>tLyE75UT2#}eKkJ=5noDX9N-~O2>A=g{g}J1 q{t3#Ut-ro$-BdwZ*7r%Im#n*F(zRa6qo^1WEr=VIAZev$@c$2DlX0^E diff --git a/backend/app/tests/test_report_processor.py b/backend/app/tests/test_report_processor.py index 3f26045..77b88cb 100644 --- a/backend/app/tests/test_report_processor.py +++ b/backend/app/tests/test_report_processor.py @@ -1,5 +1,6 @@ import pytest import threading +import asyncio from unittest.mock import patch from backend.app.services.report_processor import process_report @@ -9,20 +10,21 @@ def clear_report_store(): storage.REPORT_STORE.clear() -def test_process_report_success(): +@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.agents.price_agent.PriceAgent.get_price') as mock_get_price: - with patch('backend.app.services.agents.volume_agent.VolumeAgent.get_volume') as mock_get_volume: - with patch('backend.app.services.agents.trend_agent.TrendAgent.get_trend') as mock_get_trend: + 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_get_price.return_value = 100.0 - mock_get_volume.return_value = 1000.0 - mock_get_trend.return_value = "up" + 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} - process_report(report_id, token_id) + await process_report(report_id, token_id) assert storage.get_report_status(report_id) == "completed" report_data = storage.REPORT_STORE[report_id]["data"] @@ -30,24 +32,26 @@ def test_process_report_success(): assert report_data["volume"] == 1000.0 assert report_data["trend"] == "up" -def test_process_report_already_processing(): +@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"): - process_report(report_id, token_id) + await process_report(report_id, token_id) assert storage.get_report_status(report_id) == "processing" -def test_process_report_failure_sets_failed_status(): +@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.agents.price_agent.PriceAgent.get_price') as mock_get_price: - mock_get_price.side_effect = Exception("Agent error") + 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"): - process_report(report_id, token_id) + await process_report(report_id, token_id) assert storage.get_report_status(report_id) == "failed" @@ -79,10 +83,10 @@ def worker(): nonlocal processed_count, exception_count try: # Mock the agents to prevent actual external calls - with patch('backend.app.services.agents.price_agent.PriceAgent.get_price', return_value=100.0): - with patch('backend.app.services.agents.volume_agent.VolumeAgent.get_volume', return_value=1000.0): - with patch('backend.app.services.agents.trend_agent.TrendAgent.get_trend', return_value="up"): - process_report(report_id, token_id) + 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): diff --git a/backend/logs/app.log b/backend/logs/app.log index 73a962b..d772d8c 100644 --- a/backend/logs/app.log +++ b/backend/logs/app.log @@ -680,3 +680,118 @@ Exception: Agent failed 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.