Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix webhook bug

Tomas Valenta93a3c6aea3b1
diff --git a/api-service/agent/smol_agent.py b/api-service/agent/smol_agent.py
index a8313e6eb..41fd382d9 100644
--- a/api-service/agent/smol_agent.py
+++ b/api-service/agent/smol_agent.py
@@ -443,7 +443,18 @@ Exclusively focus on the names of the shared dependencies, and do not add any ot
},
)
)
- except:
+ except Exception as e:
+ print(f"Failed agent run {self.run_id}", e)
+ await self.on_interaction_request(
+ AgentInteractionRequest(
+ interaction_id=str(uuid.uuid4()),
+ type="failed",
+ data={
+ "run_id": self.run_id,
+ "error": str(e),
+ },
+ )
+ )
raise
finally:
if playground is not None:
diff --git a/api-service/app.py b/api-service/app.py
index 73af0bd4e..f1febfb15 100644
--- a/api-service/app.py
+++ b/api-service/app.py
@@ -6,7 +6,8 @@ from fastapi import Depends, FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from fastapi.security import OAuth2PasswordBearer
-
+from opentelemetry import metrics
+from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from agent.base import AgentInteraction
from deployment.in_memory import InMemoryDeploymentManager
@@ -119,7 +120,7 @@ async def interact_with_agent_deployment(
deployment = await deployment_manager.get_deployment(id)
if not deployment:
# Get deployment from db if enabled
- db_deployment = await db.get_deployment(id)
+ db_deployment = await db.get_deployment_by_id(id)
if (
db_deployment
and db_deployment["enabled"]
@@ -139,3 +140,6 @@ async def interact_with_agent_deployment(
if body.interaction_id:
deployment.event_handler.remove_interaction_request(body.interaction_id)
return result
+
+
+FastAPIInstrumentor.instrument_app(app)
diff --git a/api-service/database/database.py b/api-service/database/database.py
index 508454697..1d2332646 100644
--- a/api-service/database/database.py
+++ b/api-service/database/database.py
@@ -23,6 +23,17 @@ class Database:
return None if len(response.data) == 0 else response.data[0]
+ async def get_deployment_by_id(self, id: str):
+ response = (
+ await self.client.table(TABLE_DEPLOYMENTS)
+ .select("*")
+ .eq("id", id)
+ .limit(1)
+ .execute()
+ )
+
+ return None if len(response.data) == 0 else response.data[0]
+
async def get_deployments(self):
response = (
await self.client.table(TABLE_DEPLOYMENTS)