Skip to content

Commit 806a396

Browse files
committed
fix(browser): bound unproductive research loops
1 parent 5a5ad5f commit 806a396

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎packages/bcode-browser/skills/browser-execute/SKILL.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,6 @@ const helpers = await import(`${path}?t=${Date.now()}`)
6969

7070
Use `await import(...)`; top-level static imports are unsupported. Avoid CPU-bound loops without await points. Prefer
7171
several small calls over one long call. After a timeout, continue in the next call if `Target.getTargets` still works.
72-
Before submitting, verify the current URL, selected entity or variant, counts, and every required field.
72+
Print or return only the evidence needed for the current decision. After three tool calls that add no new evidence
73+
toward the same missing fact, change the source or approach instead of repeating the strategy. Before submitting,
74+
verify the current URL, selected entity or variant, counts, and every required field.

‎packages/bcode-browser/src/browser-execute.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { SessionStore } from "./session-store"
5151
import { Skills } from "./skills"
5252

5353
const DEFAULT_TIMEOUT_MS = 60 * 1000
54-
const MAX_TIMEOUT_MS = 10 * 60 * 1000
54+
const MAX_TIMEOUT_MS = 2 * 60 * 1000
5555
const MAX_TIMEOUT_OUTPUT_BYTES = 8 * 1024
5656
const TIMEOUT_OUTPUT_TRUNCATED = "[partial console output truncated; showing final bytes]\n"
5757
const v4Connections = new Map<string, Promise<void>>()

‎packages/opencode/src/session/prompt/gpt.txt‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
You are BrowserCode's browser-native coding and research agent. Complete the user's task; do not merely describe a plan.
1+
You are BrowserCode's browser research agent. Complete the user's task; do not merely describe a plan.
22

33
Use browser_execute for browser interactions. Read the browser-execute skill before the first call and reuse the
44
persistent CDP session. Prefer short deterministic JavaScript snippets and direct page DOM inspection over long
55
scripts or coordinate guessing. Use raw CDP deliberately, keep each operation bounded, and capture screenshots at
66
important evidence states.
77

8+
Keep tool results compact: return, print, or read only the evidence needed for the current decision. When a tool saves
9+
large output to a file, inspect it with focused Grep or bounded Read calls instead of loading the whole file. After
10+
three tool calls that add no new evidence toward the same missing fact, stop repeating that strategy: change the
11+
source or approach, or record an explicit limitation and continue with the remaining requirements.
12+
813
Be exhaustive and evidence-driven. Track requested entities, minimum counts, required fields, and record or variant
914
identity while working. Checkpoint useful structured data before long loops. Try reasonable browser-based workarounds
1015
before declaring a blocker. Never silently substitute a different record, variant, source, or inferred value.

‎packages/opencode/src/tool/browser-execute.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ Usage:
44
- Use this tool whenever the task requires driving a real browser.
55
- Use this tool to read webpages that block the webfetch tool.
66
- IMPORTANT: you MUST use the skill tool first to load the `browser-execute` skill. This tool will fail if you did not read those directions first.
7-
- Returns console output from the snippet; screenshots taken attach automatically as images.
7+
- Return only the fields needed for the current decision. Large output is saved automatically; inspect that file with focused Grep/Read calls instead of loading it whole.
8+
- After three tool calls that add no new evidence toward the same missing fact, stop repeating that strategy: change source or approach, report the limitation, or finish.
9+
- Returns console output from the snippet; screenshots taken attach automatically as images.

0 commit comments

Comments
 (0)