Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Reset clock drift; Fix agent cancel status update

Tomas Valenta8d5a03659c92
diff --git a/api-service/agent/smol_agent.py b/api-service/agent/smol_agent.py
index 1ed11e167..17a41b9e4 100644
--- a/api-service/agent/smol_agent.py
+++ b/api-service/agent/smol_agent.py
@@ -79,6 +79,8 @@ class SmolAgent(AgentBase):
playground = Playground(env_id="PPSrlH5TIvFx", get_envs=self.get_envs)
await playground.open()
+ fixClockDrift = asyncio.ensure_future(playground.sync_clock())
+
rootdir = "/repo"
await playground.change_rootdir(rootdir)
await playground.make_dir(rootdir)
@@ -255,6 +257,7 @@ class SmolAgent(AgentBase):
for name, content in generated_files:
await playground.write_file(os.path.join(rootdir, name), content)
+ await fixClockDrift
await playground.push_repo(
rootdir=rootdir,
repo_address=repo_address,
@@ -262,12 +265,6 @@ class SmolAgent(AgentBase):
git_email=git_app_email,
git_name=git_app_name,
)
- except:
- raise
- finally:
- if playground is not None:
- playground.close()
-
await self.on_interaction_request(
AgentInteractionRequest(
interaction_id=str(uuid.uuid4()),
@@ -277,6 +274,11 @@ class SmolAgent(AgentBase):
},
)
)
+ except:
+ raise
+ finally:
+ if playground is not None:
+ playground.close()
async def _dev_in_background(self, instructions: Any):
print("Start agent run", self._dev_loop)
@@ -288,7 +290,9 @@ class SmolAgent(AgentBase):
AgentInteractionRequest(
interaction_id=str(uuid.uuid4()),
type="cancelled",
- data={},
+ data={
+ # "associated_comment_id": self._dev_comment_id,
+ },
)
)
@@ -305,6 +309,8 @@ class SmolAgent(AgentBase):
except asyncio.TimeoutError:
await self.stop()
print("Timeout")
+ finally:
+ self._dev_loop = None
asyncio.create_task(
start_with_timeout(),
diff --git a/api-service/session/playground/base.py b/api-service/session/playground/base.py
index 92cfe2d68..cac5f2c41 100644
--- a/api-service/session/playground/base.py
+++ b/api-service/session/playground/base.py
@@ -39,6 +39,11 @@ class Playground(Session):
for open_port in open_ports
)
+ async def sync_clock(self):
+ await self.run_command(
+ "rc-service chronyd stop && chronyd -q 'server pool.ntp.org iburst'"
+ )
+
async def install_deps(self, rootdir: str):
await self.run_command("apk add npm")
await self.run_command(f"npm install --prefix {rootdir}", rootdir="/")