Skip to content

Lightpanda: the headless browser designed for AI and automation

agent: scrub remaining global-goto/extract refs from messages and docs

Adrià Arrufatf52bbc0f488a
diff --git a/docs/agent-script.md b/docs/agent-script.md
index 5048faf35..1afa501c4 100644
--- a/docs/agent-script.md
+++ b/docs/agent-script.md
@@ -392,7 +392,7 @@ Common failures:
| `page handle is no longer valid` | A page was used after a later `goto` replaced it. Read a page before navigating away. |
| `ReferenceError: document is not defined` | You tried to use browser DOM APIs in the agent context. Use `page.extract(...)` or `page.evaluate(...)`. |
| `ReferenceError: require is not defined` | Agent scripts are not Node.js scripts. |
-| `no page loaded - run goto(url) first` | A page-dependent primitive ran before navigation. |
+| `no page loaded - run page.goto(url) first` | A page method ran before navigation. |
| `invalid arguments` | A method received the wrong number or shape of arguments, or a non-JSON-serializable value. |
| `extract: no schema selector matched any element` | Every field in the schema missed. Fix the selectors; an empty page section yields `null`/`[]` per field, not this error. |
diff --git a/docs/agent.md b/docs/agent.md
index c8bda8b62..9a82187ca 100644
--- a/docs/agent.md
+++ b/docs/agent.md
@@ -95,11 +95,11 @@ The whole value of a saved script is that it keeps working after you walk away.
- **Ask for the data you want, not the conversation about it.** "Get me the
top 5 HN story titles and points, print them to stdout" beats "show me
what's on Hacker News today." The synthesizer captures the data you asked
- for as an `extract()` call; vague prompts produce vague recordings.
+ for as a `page.extract()` call; vague prompts produce vague recordings.
- **Be specific about the page.** "Go to news.ycombinator.com" is much
better than "find me what's on Hacker News".
- **Check the file with `cat your-script.js` before running it.** The
- script holds the *calls*, not the data, so look for an `extract(...)`
+ script holds the *calls*, not the data, so look for a `page.extract(...)`
whose schema covers the fields you asked for. If there isn't one, the
recording missed something — try rewording your prompt.
- **When the page changes and a saved script breaks**, re-run with the LLM,
diff --git a/src/agent/Agent.zig b/src/agent/Agent.zig
index cb95d77ca..3f459bb34 100644
--- a/src/agent/Agent.zig
+++ b/src/agent/Agent.zig
@@ -181,7 +181,7 @@ const script_skill =
\\| `page handle is no longer valid` | Used a page after a later `goto` replaced it → read a page before navigating away |
\\| `document is not defined` | DOM API in script context → use `page.extract` or `page.evaluate` |
\\| `require is not defined` | Not Node.js |
- \\| `no page loaded - run goto(url) first` | Page primitive before navigation |
+ \\| `no page loaded - run page.goto(url) first` | Page method before navigation |
\\| `invalid arguments` | Wrong arity/shape, non-JSON value, or a field set both positionally and in options |
\\| `extract: no schema selector matched any element` | All schema fields missed → fix selectors |
\\| `press` fails with one string arg | Selector-first: use `page.press(null, "Enter")` or `page.press({ key: "Enter" })` |
diff --git a/src/script/Runtime.zig b/src/script/Runtime.zig
index ff667b09e..9e2c5e808 100644
--- a/src/script/Runtime.zig
+++ b/src/script/Runtime.zig
@@ -562,7 +562,7 @@ fn callTool(
const result = browser_tools.call(arena, self.session, self.registry, @tagName(tool), args) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
- error.FrameNotLoaded => return .{ .fail = "no page loaded - run goto(url) first" },
+ error.FrameNotLoaded => return .{ .fail = "no page loaded - run page.goto(url) first" },
else => return .{ .fail = std.fmt.allocPrint(arena, "{s} failed: {s}", .{ @tagName(tool), @errorName(err) }) catch return error.OutOfMemory },
};