Skip to content

Commit ec490ca

Browse files
committed
browser_execute: resolve harness path in tool description
The description references SKILL.md and helpers.py by source-tree path, which only resolves correctly in dev mode. In compiled binaries the harness extracts to <dataDir>/harness/ and those source paths don't exist on disk, so the agent's first read fails. Template the path: replace packages/bcode-browser/harness/ with {{HARNESS_DIR}} in the description, and substitute the resolved path (dev or compiled) in the opencode adapter at make-time. Eager harness extraction (already in the data-dir relocation commit) guarantees the files exist before the agent reads the description.
1 parent a22a4c5 commit ec490ca

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const make = Effect.fn("BrowserExecute.make")(function* (dataDir: string)
157157
}),
158158
)
159159

160-
return { parameters, execute }
160+
return { parameters, execute, harnessDir }
161161
})
162162

163163
export * as BrowserExecute from "./browser-execute"

packages/opencode/src/tool/browser-execute.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export const BrowserExecuteTool = Tool.define(
1717
Effect.gen(function* () {
1818
const impl = yield* BrowserExecute.make(Global.Path.data)
1919
return {
20-
description: DESCRIPTION,
20+
// Substitute the resolved harness path (dev: repo path; compiled:
21+
// <dataDir>/harness/) so the SKILL.md / helpers.py references in the
22+
// description point at files that actually exist on disk.
23+
description: DESCRIPTION.replaceAll("{{HARNESS_DIR}}", impl.harnessDir),
2124
parameters: impl.parameters,
2225
execute: (args: Schema.Schema.Type<typeof impl.parameters>, ctx: Tool.Context) =>
2326
Effect.gen(function* () {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Execute Python against a connected web browser via the BrowserCode harness.
22

33
Use this tool whenever the task requires driving a real browser — automation, scraping, end-to-end testing, or interactive exploration. The harness attaches to the user's running Chrome (local) or a Browser Use cloud browser (remote). A session-scoped daemon holds the CDP connection so consecutive calls share the same browser and tabs.
44

5-
Before the first `browser_execute` call of a session, you MUST read `packages/bcode-browser/harness/SKILL.md`. It defines the helper surface, the screenshot-driven workflow, remote-browser setup, and gotchas — none of that is repeated here.
5+
Before the first `browser_execute` call of a session, you MUST read `{{HARNESS_DIR}}/SKILL.md`. It defines the helper surface, the screenshot-driven workflow, remote-browser setup, and gotchas — none of that is repeated here.
66

7-
Optional: read `packages/bcode-browser/harness/src/browser_harness/helpers.py` when you need an exact signature that SKILL.md does not show.
7+
Optional: read `{{HARNESS_DIR}}/src/browser_harness/helpers.py` when you need an exact signature that SKILL.md does not show.

0 commit comments

Comments
 (0)