From 6fb2c544d3e12d482ac1b71bfd462148c8127076 Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Thu, 5 Jun 2025 11:21:34 +0000 Subject: [PATCH] fix(agent): increase timeout for pending Redis operations and improve error logging for cost calculation --- backend/agentpress/response_processor.py | 6 +++--- backend/run_agent_background.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/agentpress/response_processor.py b/backend/agentpress/response_processor.py index 457e20ba..4541491c 100644 --- a/backend/agentpress/response_processor.py +++ b/backend/agentpress/response_processor.py @@ -578,8 +578,8 @@ class ResponseProcessor: logger.info("Stream cost calculation resulted in zero or None, not storing cost message.") self.trace.update(metadata={"cost": 0}) except Exception as e: - logger.error(f"Error calculating final cost for stream: {str(e)}") - self.trace.event(name="error_calculating_final_cost_for_stream", level="ERROR", status_message=(f"Error calculating final cost for stream: {str(e)}")) + logger.warning(f"Failed to calculate final cost for stream: {str(e)}") + self.trace.event(name="failed_to_calculate_final_cost_for_stream", level="WARNING", status_message=(f"Failed to calculate final cost for stream: {str(e)}")) # --- Final Finish Status --- @@ -1069,7 +1069,7 @@ class ResponseProcessor: "arguments": params # The extracted parameters } - logger.debug(f"Created tool call: {tool_call}") + # logger.debug(f"Created tool call: {tool_call}") return tool_call, parsing_details # Return both dicts except Exception as e: diff --git a/backend/run_agent_background.py b/backend/run_agent_background.py index cf9715b9..2d488374 100644 --- a/backend/run_agent_background.py +++ b/backend/run_agent_background.py @@ -235,7 +235,7 @@ async def run_agent_background( # Wait for all pending redis operations to complete, with timeout try: - await asyncio.wait_for(asyncio.gather(*pending_redis_operations), timeout=5.0) + await asyncio.wait_for(asyncio.gather(*pending_redis_operations), timeout=30.0) except asyncio.TimeoutError: logger.warning(f"Timeout waiting for pending Redis operations for {agent_run_id}")