Miquel Farré
commited on
Commit
·
2defc46
1
Parent(s):
6da76f0
stoping agent when desktop not available
Browse files- e2bqwen.py +10 -0
e2bqwen.py
CHANGED
|
@@ -398,6 +398,16 @@ REMEMBER TO ALWAYS CLICK IN THE MIDDLE OF THE TEXT, NOT ON THE SIDE, NOT UNDER.
|
|
| 398 |
"""Callback that takes a screenshot + memory snapshot after a step completes"""
|
| 399 |
current_step = memory_step.step_number
|
| 400 |
print(f"Taking screenshot for step {current_step}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
try:
|
| 402 |
time.sleep(2.0) # Let things happen on the desktop
|
| 403 |
screenshot_bytes = self.desktop.screenshot()
|
|
|
|
| 398 |
"""Callback that takes a screenshot + memory snapshot after a step completes"""
|
| 399 |
current_step = memory_step.step_number
|
| 400 |
print(f"Taking screenshot for step {current_step}")
|
| 401 |
+
# Check if desktop is still running
|
| 402 |
+
if not self.desktop.is_running():
|
| 403 |
+
print("Desktop is no longer running. Terminating agent.")
|
| 404 |
+
self.close()
|
| 405 |
+
# Add a final observation indicating why the agent was terminated
|
| 406 |
+
memory_step.observations = "Desktop session ended. Agent terminated."
|
| 407 |
+
# Store final metadata before exiting
|
| 408 |
+
self.store_metadata_to_file(agent)
|
| 409 |
+
return # Exit the callback without attempting to take a screenshot
|
| 410 |
+
|
| 411 |
try:
|
| 412 |
time.sleep(2.0) # Let things happen on the desktop
|
| 413 |
screenshot_bytes = self.desktop.screenshot()
|