Skip to content

Commit eb5d6a1

Browse files
committed
Refine CUA drag batching guidance and quiet Python transport logs.
Steer the templates away from batching layout-changing drags and suppress noisy httpx request logs so local runs stay readable without hiding the template's own events. Made-with: Cursor
1 parent 11595f9 commit eb5d6a1

5 files changed

Lines changed: 16 additions & 0 deletions

File tree

pkg/templates/python/openai-computer-use/agent/agent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
For drag actions in batch_computer_actions:
4040
- Always include a path field.
4141
- path must be an array of at least two points.
42+
- If one drag is likely to change the position, order, or layout of other targets, do not batch multiple drags together.
43+
- In those cases, prefer one drag at a time and inspect the updated screenshot before planning the next drag.
4244
- Each point must be an object like {"x": 123, "y": 456}."""
4345

4446
BATCH_TOOL = {

pkg/templates/python/openai-computer-use/agent/logging.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import sys
23
import threading
34
import time
@@ -7,6 +8,13 @@
78
MAX_LINE_WIDTH = 120
89

910

11+
def quiet_http_transport_logs() -> None:
12+
# The Kernel Python SDK uses httpx underneath, and those request logs can
13+
# become noisy when the surrounding process configures root logging at INFO.
14+
logging.getLogger("httpx").setLevel(logging.WARNING)
15+
logging.getLogger("httpcore").setLevel(logging.WARNING)
16+
17+
1018
def _timestamp() -> str:
1119
return datetime.now().strftime("%H:%M:%S.%f")[:-3]
1220

pkg/templates/python/openai-computer-use/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
emit_browser_new_done,
1313
emit_browser_new_started,
1414
emit_session_state,
15+
quiet_http_transport_logs,
1516
)
1617
from computers.kernel_computer import KernelComputer
1718
from kernel import Kernel
@@ -42,6 +43,7 @@ class CuaOutput(TypedDict):
4243
if not api_key:
4344
raise ValueError("OPENAI_API_KEY is not set")
4445

46+
quiet_http_transport_logs()
4547
client = Kernel()
4648
app = kernel.App("python-openai-cua")
4749

pkg/templates/python/openai-computer-use/run_local.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
emit_browser_new_done,
2424
emit_browser_new_started,
2525
emit_session_state,
26+
quiet_http_transport_logs,
2627
)
2728
from computers.kernel_computer import KernelComputer
2829

@@ -51,6 +52,7 @@ def main():
5152
if not os.getenv("OPENAI_API_KEY"):
5253
raise ValueError("OPENAI_API_KEY is not set")
5354

55+
quiet_http_transport_logs()
5456
client = Kernel(api_key=os.getenv("KERNEL_API_KEY"))
5557
on_event = create_event_logger(verbose=args.debug)
5658

pkg/templates/typescript/openai-computer-use/lib/toolset.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ When interacting with page content (search boxes, forms, chat inputs):
1919
For drag actions in batch_computer_actions:
2020
- Always include a path field.
2121
- path must be an array of at least two points.
22+
- If one drag is likely to change the position, order, or layout of other targets, do not batch multiple drags together.
23+
- In those cases, prefer one drag at a time and inspect the updated screenshot before planning the next drag.
2224
- Each point must be an object like {"x": 123, "y": 456}.`;
2325

2426
export const batchComputerTool = {

0 commit comments

Comments
 (0)