Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Normalize common LLM output errors

Dillon DuPonte261282182a0
diff --git a/libs/python/agent/agent/agent.py b/libs/python/agent/agent/agent.py
index 78fc3f45e5..fb9a45d9d4 100644
--- a/libs/python/agent/agent/agent.py
+++ b/libs/python/agent/agent/agent.py
@@ -29,6 +29,7 @@ from .callbacks import (
TrajectorySaverCallback,
BudgetManagerCallback,
TelemetryCallback,
+ OperatorValidatorCallback
)
from .computers import (
AsyncComputerHandler,
@@ -201,6 +202,9 @@ class ComputerAgent:
# == Add built-in callbacks ==
+ # Prepend operator validator callback
+ self.callbacks.insert(0, OperatorValidatorCallback())
+
# Add telemetry callback if telemetry_enabled is set
if self.telemetry_enabled:
if isinstance(self.telemetry_enabled, bool):
diff --git a/libs/python/agent/agent/callbacks/__init__.py b/libs/python/agent/agent/callbacks/__init__.py
index ffe34551fc..35ab026339 100644
--- a/libs/python/agent/agent/callbacks/__init__.py
+++ b/libs/python/agent/agent/callbacks/__init__.py
@@ -8,6 +8,7 @@ from .logging import LoggingCallback
from .trajectory_saver import TrajectorySaverCallback
from .budget_manager import BudgetManagerCallback
from .telemetry import TelemetryCallback
+from .operator_validator import OperatorValidatorCallback
__all__ = [
"AsyncCallbackHandler",
@@ -16,4 +17,5 @@ __all__ = [
"TrajectorySaverCallback",
"BudgetManagerCallback",
"TelemetryCallback",
+ "OperatorValidatorCallback",
]