Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Add run id to analytics events

Tomas Valentaf3b0efb11a58
diff --git a/api-service/agent/smol_agent.py b/api-service/agent/smol_agent.py
index 1111f45da..a8313e6eb 100644
--- a/api-service/agent/smol_agent.py
+++ b/api-service/agent/smol_agent.py
@@ -184,7 +184,7 @@ Begin generating the code now.
"cost": cost,
}
- async def _dev(self, instructions: Any):
+ async def _dev(self, run_id: str, instructions: Any):
user_prompt: str = instructions["Prompt"]
access_token: str = instructions["AccessToken"]
repo: str = instructions["Repo"]
@@ -194,8 +194,6 @@ Begin generating the code now.
git_app_email: str = instructions["GitHubAppEmail"]
commit_message: str = instructions["CommitMessage"]
- run_id = str(uuid.uuid4())
-
repo_address = (
f"https://{git_app_name}:{access_token}@github.com/{owner}/{repo}.git"
)
@@ -441,6 +439,7 @@ Exclusively focus on the names of the shared dependencies, and do not add any ot
type="done",
data={
"prompt": user_prompt,
+ "run_id": self.run_id,
},
)
)
@@ -467,10 +466,12 @@ Exclusively focus on the names of the shared dependencies, and do not add any ot
print("Agent run already in progress - restarting")
await self.stop()
+ self.run_id = str(uuid.uuid4())
+
async def start_with_timeout():
try:
self._dev_loop = asyncio.create_task(
- self._dev(instructions=instructions),
+ self._dev(run_id=self.run_id, instructions=instructions),
)
await asyncio.wait_for(
self._dev_loop,
@@ -501,7 +502,7 @@ Exclusively focus on the names of the shared dependencies, and do not add any ot
interaction_id=str(uuid.uuid4()),
type="cancelled",
data={
- # "associated_comment_id": self._dev_comment_id,
+ "run_id": self.run_id,
},
)
)
diff --git a/pages/api/agent/run.ts b/pages/api/agent/run.ts
index 67e6281e3..c5b2ede4e 100644
--- a/pages/api/agent/run.ts
+++ b/pages/api/agent/run.ts
@@ -14,9 +14,11 @@ async function postRun(req: NextApiRequest, res: NextApiResponse) {
const {
deployment_id,
prompt,
+ run_id,
} = req.body as {
prompt: string,
deployment_id: string,
+ run_id: string,
}
const header = req.headers.authorization
@@ -79,6 +81,7 @@ async function postRun(req: NextApiRequest, res: NextApiResponse) {
agent_deployment_id: deployment.id,
agent: TemplateID.SmolDeveloper,
repository: `${authData.github.owner}/${authData.github.repo}`,
+ run_id,
pr_number: authData.github.pr_number,
},
@@ -100,7 +103,11 @@ async function deleteRun(req: NextApiRequest, res: NextApiResponse) {
try {
const {
deployment_id,
- } = req.body as { deployment_id: string }
+ run_id,
+ } = req.body as {
+ deployment_id: string,
+ run_id: string,
+ }
const header = req.headers.authorization
// Extract the token from the header
@@ -158,6 +165,7 @@ async function deleteRun(req: NextApiRequest, res: NextApiResponse) {
agent_deployment_id: deployment.id,
agent: TemplateID.SmolDeveloper,
repository: `${authData.github.owner}/${authData.github.repo}`,
+ run_id,
pr_number: authData.github.pr_number,
},