fix: complete OPC system implementation
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 10m4s
Run Tests / Frontend Tests (push) Failing after 14m28s
Run Tests / Backend Tests (push) Failing after 14m50s
Run Tests / Test Summary (push) Has been cancelled

- Add database connection retry logic (3 attempts, 5s delay)
- Add missing database functions: get_task_by_id, get_agent_execution, approve_agent_execution, update_agent_config, update_execution_status
- Complete agent execution approval workflow
- Fix agent executor to handle approved executions
- Fix inefficient task queries (use direct ID lookup)
- Add error action handling in agent executor
- Improve LiteLLM error handling with specific exception types
- Reduce LiteLLM timeout from 60s to 30s
- Fix execution status update to only set started_at once
- Consolidate WebSocket datetime serialization with helper function
- Implement update agent endpoint
This commit is contained in:
Gan, Jimmy
2026-04-03 22:30:51 +08:00
parent a42e3d3050
commit 5da2ae01a0
5 changed files with 333 additions and 56 deletions
@@ -76,6 +76,9 @@ Only propose actions you can actually execute. Be specific and actionable."""
async def _call_llm(self, prompt: str) -> str:
"""Call LiteLLM proxy"""
import logging
logger = logging.getLogger(__name__)
model = self.config.get("model", "claude-sonnet-4-6")
temperature = self.config.get("temperature", 0.7)
@@ -85,7 +88,7 @@ Only propose actions you can actually execute. Be specific and actionable."""
if self.litellm_api_key and self.litellm_api_key.strip():
headers["Authorization"] = f"Bearer {self.litellm_api_key}"
async with httpx.AsyncClient(timeout=60.0) as client:
async with httpx.AsyncClient(timeout=30.0) as client:
response = await client.post(
f"{self.litellm_url}/chat/completions",
headers=headers,
@@ -102,7 +105,17 @@ Only propose actions you can actually execute. Be specific and actionable."""
response.raise_for_status()
data = response.json()
return data["choices"][0]["message"]["content"]
except httpx.ConnectError as e:
logger.error(f"LiteLLM connection failed: {e}")
raise Exception(f"LiteLLM service unavailable: {str(e)}")
except httpx.TimeoutException as e:
logger.error(f"LiteLLM request timeout: {e}")
raise Exception(f"LiteLLM request timeout: {str(e)}")
except httpx.HTTPStatusError as e:
logger.error(f"LiteLLM HTTP error: {e.response.status_code} - {e.response.text}")
raise Exception(f"LiteLLM HTTP error {e.response.status_code}: {e.response.text}")
except Exception as e:
logger.error(f"LiteLLM call failed: {e}")
raise Exception(f"LLM call failed: {str(e)}")
def _parse_response(self, response: str) -> Dict[str, Any]: