Skip to content

The agent that grows with you

fix(tools): gate the set_value verdict on type_text_incomplete

Brooklyn Nicholsonf26a0949a413
diff --git a/tests/tools/test_computer_use_zero_delivery_verdict.py b/tests/tools/test_computer_use_zero_delivery_verdict.py
index ef002afed86..692faf0b849 100644
--- a/tests/tools/test_computer_use_zero_delivery_verdict.py
+++ b/tests/tools/test_computer_use_zero_delivery_verdict.py
@@ -29,3 +29,23 @@ def test_zero_delivery_recommends_set_value():
def test_partial_delivery_keeps_generic_ladder():
verdict = _classify_action_result(_result(7))
assert verdict.get("recommended") != "set_value"
+
+
+def test_synthesis_budget_refusal_keeps_driver_recommendation():
+ """`type_text_synthesis_budget_exceeded` also reports delivered 0 (the
+ budget declined to emit at all), but the target is not dropping
+ keystrokes — re-routing it to set_value would replace the driver's own
+ `chunk` retry instruction with a different write path."""
+ verdict = _classify_action_result(
+ ActionResult(
+ ok=True,
+ action="type",
+ message="type_text synthesis budget exceeded",
+ code="type_text_synthesis_budget_exceeded",
+ meta={"delivered_chars": 0, "requested_chars": 6500},
+ escalation={"recommended": "chunk", "reason": "requested run exceeds the synthesis budget"},
+ )
+ )
+ assert verdict["decision"] == "escalate"
+ assert verdict["recommended"] == "chunk"
+ assert "set_value" not in verdict["hint"]
diff --git a/tools/computer_use/tool.py b/tools/computer_use/tool.py
index b8e341e651c..dd2a0397611 100644
--- a/tools/computer_use/tool.py
+++ b/tools/computer_use/tool.py
@@ -533,21 +533,27 @@ def _classify_action_result(res: ActionResult) -> Dict[str, Any]:
delivered, requested = meta.get("delivered_chars"), meta.get("requested_chars")
if (
res.action in ("type", "type_text")
+ and res.code == "type_text_incomplete"
and isinstance(delivered, int)
and isinstance(requested, int)
and requested > 0
and delivered <= 0
):
- # Zero delivery: the field swallowed every synthetic keystroke (trusted-event checks on web
- # inputs do this). Neither rung of the delivery ladder can fix a target that drops events at
- # the source — the AX set_value path writes the value directly and bypasses event filtering.
+ # Zero delivery on the driver's own partial-delivery verdict: the field swallowed every
+ # synthetic keystroke (trusted-event checks on web inputs do this). Neither rung of the
+ # delivery ladder can fix a target that drops events at the source — the AX set_value
+ # path writes the value directly and bypasses event filtering. The code gate matters:
+ # `type_text_synthesis_budget_exceeded` also reports delivered 0, but that is the bounded
+ # synthesis budget declining to emit at all, and the driver's own `chunk` recommendation
+ # stays the right next step there.
return {
"decision": "escalate",
"recommended": "set_value",
"hint": (
"0 characters landed: this input drops synthetic keystrokes, so no delivery rung will fix it. "
- "Use set_value on the field's element index instead — it sets the value through the "
- "accessibility API and bypasses event filtering. Re-capture first if the index is stale."
+ "Climb to the set_value action on the field's element index instead — it is an action, not a "
+ "delivery mode, and sets the value through the accessibility API, bypassing event filtering. "
+ "Re-capture first if the index is stale."
),
}
return {"decision": "escalate", **({"recommended": res.escalation.get("recommended")}