Skip to content

Commit 01281ad

Browse files
authored
refactor(browser): remove model-backed page extraction (#120101)
* refactor(browser): remove model-backed extraction * docs(browser): remove stale extract reference
1 parent 53006a2 commit 01281ad

34 files changed

Lines changed: 21 additions & 2162 deletions

‎docs/cli/browser.md‎

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,7 @@ openclaw browser close t1
135135
136136
Raw target ids are volatile diagnostic handles, not durable agent memory: when Chromium replaces the underlying raw target during a navigation or form submit, OpenClaw keeps the stable `tabId`/label attached to the replacement tab when it can prove the match. Prefer `suggestedTargetId`.
137137
138-
## Extract / snapshot / screenshot / actions
139-
140-
Answer a question from the current page without printing the page content:
141-
142-
```bash
143-
openclaw browser extract "What is the main conclusion?"
144-
openclaw browser extract "Which deadline is listed?" --target-id docs --timeout-ms 90000
145-
openclaw browser extract "List the releases" --selector "main" --ignore-selector "nav" --schema '{"type":"array","items":{"type":"object"}}'
146-
```
147-
148-
`extract` uses the selected agent model, returns only the wrapped answer, and
149-
reports `NOT_FOUND` when the answer is absent. Its overall timeout defaults to
150-
60 seconds and is clamped to 5–120 seconds. It requires a Playwright-backed
151-
profile; use `snapshot` when you need refs or when extraction is unavailable.
152-
Use `--selector <css>` to limit large pages to matching subtrees and repeat
153-
`--ignore-selector <css>` to remove navigation, footers, ads, or banners before
154-
conversion. `--schema <json>` requests validated structured output in
155-
`details.json`; invalid structured output is retried once, then fails with
156-
guidance to retry without the schema.
138+
## Snapshot / screenshot / actions
157139
158140
Snapshot:
159141
@@ -293,7 +275,7 @@ Current existing-session limits:
293275
- File uploads require `--ref` / `--input-ref`, do not support CSS `--element`, and support one file at a time.
294276
- Dialog hooks do not support `--timeout`.
295277
- Screenshots support page captures and `--ref`, but not CSS `--element`.
296-
- `extract`, `responsebody`, download interception, PDF export, and batch actions still require a managed browser or raw CDP profile.
278+
- `responsebody`, download interception, PDF export, and batch actions still require a managed browser or raw CDP profile.
297279
298280
## Remote browser control (node host proxy)
299281

‎docs/tools/browser-control.md‎

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ agent tools, but nothing listens on the loopback control port.
2323
- Status/start/stop: `GET /`, `GET /doctor`, `POST /start`, `POST /stop`, `POST /reset-profile`
2424
- Profiles: `GET /profiles`, `POST /profiles/create`, `DELETE /profiles/:name`
2525
- Tabs: `GET /tabs`, `POST /tabs/open`, `POST /tabs/focus`, `DELETE /tabs/:targetId`, `POST /tabs/action`
26-
- Snapshot/screenshot/extract: `GET /snapshot`, `POST /screenshot`, `POST /extract`
26+
- Snapshot/screenshot: `GET /snapshot`, `POST /screenshot`
2727
- Actions: `POST /navigate`, `POST /act`
2828
- Hooks: `POST /hooks/file-chooser`, `POST /hooks/dialog`
2929
- Downloads: `POST /download`, `POST /wait/download`
@@ -49,27 +49,6 @@ For tab endpoints, `targetId` is the compatibility field name. Prefer passing
4949
handles such as `t1` are also accepted. Raw CDP target ids and unique raw
5050
target-id prefixes still work, but they are volatile diagnostic handles.
5151

52-
### Page extraction
53-
54-
The agent tool accepts `action="extract"` with required `query` and optional
55-
`targetId`, `timeoutMs`, `selector`, `ignoreSelectors`, and `schema`. `selector`
56-
is a CSS selector that limits capture to matching subtrees; a no-match response
57-
is an error and never falls back to the whole page. `ignoreSelectors` is an
58-
array of CSS selectors removed from the captured subtree before readable text
59-
conversion, so navigation, footers, ads, and banners do not consume the model
60-
context window. The reported `chars` count reflects the scoped, converted text.
61-
62-
`schema` is a JSON Schema object for structured extraction. A successful result
63-
stores the validated value in `details.json` and shows compact JSON in the
64-
wrapped text block. Invalid JSON or a schema mismatch gets one correction retry;
65-
if that also fails, retry without `schema` or adjust the schema. Without
66-
`schema`, extraction keeps its free-text answer and `NOT_FOUND` behavior.
67-
68-
The CLI mirrors these fields with `--selector <css>`, repeatable
69-
`--ignore-selector <css>`, and `--schema <json>`. The private `POST /extract`
70-
capture route accepts `targetId`, `timeoutMs`, `selector`, and
71-
`ignoreSelectors`; schema validation happens in the calling agent tool or CLI.
72-
7352
If shared-secret gateway auth is configured, browser HTTP routes require auth too:
7453

7554
- `Authorization: Bearer <gateway token>`
@@ -105,7 +84,7 @@ Other runtime failures may still return `{ "error": "<message>" }` without a
10584

10685
### Playwright requirement
10786

108-
Some features (navigate/act/AI snapshot/role snapshot, extract, element
87+
Some features (navigate/act/AI snapshot/role snapshot, element
10988
screenshots, PDF) require Playwright. If Playwright isn't installed, those endpoints return
11089
a clear 501 error.
11190

@@ -128,7 +107,6 @@ What still needs Playwright:
128107
- AI snapshots that depend on Playwright's native AI snapshot format
129108
- CSS-selector element screenshots (`--element`)
130109
- full browser PDF export
131-
- page-question extraction
132110

133111
Element screenshots also reject `--full-page`; the route returns `fullPage is
134112
not supported for element screenshots`.
@@ -214,8 +192,6 @@ openclaw browser snapshot --urls
214192
openclaw browser snapshot --selector "#main" --interactive
215193
openclaw browser snapshot --frame "iframe#main" --interactive
216194
openclaw browser snapshot --out snapshot.txt
217-
openclaw browser extract "What is the page's main conclusion?"
218-
openclaw browser extract "List the releases" --selector "main" --ignore-selector "nav" --schema '{"type":"array","items":{"type":"object"}}'
219195
openclaw browser console --level error
220196
openclaw browser errors --clear
221197
openclaw browser requests --filter api --clear
@@ -283,12 +259,6 @@ openclaw browser set device "iPhone 14"
283259
284260
Notes:
285261
286-
- Use `browser extract "<question>"` or agent-tool `action="extract"` when you
287-
need an answer from the current page but do not need interaction refs. It
288-
sanitizes readable page content, caps it at 80,000 characters, runs one
289-
model call, and returns only the wrapped answer. The overall timeout defaults
290-
to 60 seconds and is clamped to 5–120 seconds. If extraction fails, fall back
291-
to `snapshot`; existing-session profiles do not support extraction.
292262
- The agent-facing `browser` tool exposes `action=download` (required `ref` and
293263
`path`) and `action=waitfordownload` (optional `path`). Both return the saved
294264
download URL, suggested filename, and guarded local path. Explicit download

‎docs/tools/browser.md‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,10 @@ Plugin-bundled skills are listed in the agent's available skills when the
102102
plugin is enabled. The full skill instructions load on demand, so routine
103103
turns do not pay the full token cost.
104104

105-
For “read this page and answer X,” use browser `action="extract"` with a
106-
`query`. It sends sanitized, bounded readable text through one model call and
107-
returns only the answer; keep `snapshot` for choosing actions and obtaining
108-
refs. Extraction requires a Playwright-backed profile and falls back to a
109-
snapshot workflow when it cannot complete.
110-
111-
On large pages, pass `selector` to capture only the relevant CSS subtree and
112-
`ignoreSelectors` to remove repeated chrome before conversion. Pass a JSON
113-
`schema` when the caller needs validated machine-usable fields in
114-
`details.json`; without it, extraction remains a free-text answer.
105+
For page text, use a selector-scoped snapshot or `act:evaluate` that returns
106+
only the relevant text or structured data, then let the active agent model
107+
reason over that bounded result. Use efficient snapshots for controls and
108+
action discovery; they intentionally omit most non-interactive prose.
115109

116110
## Missing browser command or tool
117111

‎extensions/browser/index.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ describe("browser plugin", () => {
260260
await tool.execute("call-1", { action: "status" });
261261
expect(runtimeApiMocks.createBrowserTool).toHaveBeenCalledWith({
262262
agentSessionKey: "agent:main:webchat:direct:123",
263-
agentId: "main",
264263
agentDir: "/tmp/agent",
265264
workspaceDir: "/tmp/workspace",
266265
activeModel: { provider: "openai", model: "gpt-5.5" },

‎extensions/browser/plugin-registration.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function createLazyBrowserTool(opts?: {
6767
sandboxBridgeUrl?: string;
6868
allowHostControl?: boolean;
6969
agentSessionKey?: string;
70-
agentId?: string;
7170
agentDir?: string;
7271
workspaceDir?: string;
7372
activeModel?: {
@@ -112,7 +111,6 @@ function createBrowserToolOptions(ctx: OpenClawPluginToolContext): {
112111
sandboxBridgeUrl?: string;
113112
allowHostControl?: boolean;
114113
agentSessionKey?: string;
115-
agentId?: string;
116114
agentDir?: string;
117115
workspaceDir?: string;
118116
activeModel?: {
@@ -134,7 +132,6 @@ function createBrowserToolOptions(ctx: OpenClawPluginToolContext): {
134132
? { allowHostControl: ctx.browser.allowHostControl }
135133
: {}),
136134
...(ctx.sessionKey ? { agentSessionKey: ctx.sessionKey } : {}),
137-
...(ctx.agentId ? { agentId: ctx.agentId } : {}),
138135
...(ctx.agentDir ? { agentDir: ctx.agentDir } : {}),
139136
...(ctx.workspaceDir ? { workspaceDir: ctx.workspaceDir } : {}),
140137
...(ctx.activeModel?.provider || ctx.activeModel?.modelId

‎extensions/browser/skills/browser-automation/SKILL.md‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ Use this skill when you need the `browser` tool for anything beyond a single pag
2121
- `suggestedTargetId` is the label when one exists, otherwise the stable `tabId` handle like `t1`.
2222
- Avoid relying on raw DevTools `targetId` except for immediate diagnostics; it can change under Chromium target replacement.
2323
3. Read before you click:
24-
- For “read the page and answer X,” use `action="extract"` with `query` so only the answer returns.
25-
- Prefer `selector` to scope extraction on large pages and list views; use `ignoreSelectors` to drop repeated chrome.
26-
- Use `schema` when downstream work needs validated, machine-usable fields instead of prose.
27-
- For virtualized lists, scroll through each segment, extract it, then merge the structured results.
28-
- Use `action="snapshot"` instead when you need action refs or page structure.
29-
- If extract returns `NOT_FOUND` or asks for snapshot fallback, inspect the page with a snapshot.
24+
- For “read the page and answer X,” use a selector-scoped `action="snapshot"` or `act:evaluate` that returns only relevant text or structured data. Let the active agent model answer from that bounded result; use efficient snapshots for controls and action discovery because they omit most non-interactive prose.
25+
- For virtualized lists, scroll through each segment, capture only the relevant rows, then merge the results.
3026
- Use `action="snapshot"` on the intended `targetId`.
3127
- Use the same `targetId` for follow-up actions so refs stay on the same tab.
3228
- For durable Playwright refs, request `refs="aria"` when supported. If you receive `axN` refs from `snapshotFormat="aria"`, use them only after that same snapshot call; stale or unbound `axN` refs fail fast and need a fresh snapshot.

0 commit comments

Comments
 (0)