Page Agent’s tool system is fully extensible. By providing aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alibaba/page-agent/llms.txt
Use this file to discover all available pages before exploring further.
customTools map at construction time, you can add new capabilities backed by your own business logic, override the behavior of built-in tools, or remove tools entirely. Each tool’s input schema is defined with Zod, giving you compile-time safety and automatic validation.
Zod Version Note
Page Agent uses Zod for tool input schemas. Both Zod 3 (≥ 3.25.0) and Zod 4 are supported. Always import from thezod/v4 subpath regardless of which version you have installed. Zod Mini is not supported.
Defining a Custom Tool
Use thetool() helper exported from page-agent to define each tool. Every tool requires three fields:
A clear description of what the tool does. The LLM uses this to decide when to call it — write it as you would a docstring for a human reader.
A Zod object schema describing the tool’s input parameters. Defaults and optional fields are respected.
The function called when the LLM invokes the tool. Receives the validated
input and a context object { signal }. Must return a string result. this inside execute is the PageAgentCore instance.Overriding a Built-in Tool
Pass a tool with the same name as a built-in tool to replace its implementation entirely. The original behavior is discarded.Removing a Built-in Tool
Set a tool’s value tonull to prevent the agent from ever calling it:
Removing tools is useful when you want to restrict the agent’s action space — for example, removing
ask_user forces the agent to complete tasks without asking for clarification.Execute Context
Inside everyexecute function:
| Context | Type | Description |
|---|---|---|
this | PageAgentCore | The agent instance. Access agent state, history, and internal APIs. |
ctx.signal | AbortSignal | Fires when the task is cancelled. Pass to fetch and other async ops. |
Built-in Tools Reference
These tools are available by default. Override or remove them viacustomTools.
| Tool | Description |
|---|---|
done | Mark the task as complete and return a result to the caller. |
wait | Wait for 1–10 seconds. Useful to let the page or data fully load before the next step. |
ask_user | Ask the user a question and wait for their typed reply. Automatically removed from the tool list if onAskUser is not configured. |
click_element_by_index | Click an element by its index in the simplified interactive element tree. |
input_text | Click and type text into an interactive input element. |
select_dropdown_option | Select a dropdown option by the text of the option. Requires both element index and option text. |
scroll | Scroll vertically. Without index: scrolls the document. With index: scrolls the container at that index (or its nearest scrollable ancestor). |
scroll_horizontally | Scroll the page or a container horizontally. Requires pixels (number of pixels; right direction defaults to true). |
execute_javascript | Execute a JavaScript snippet on the page. Experimental — disabled by default. |
The execute_javascript Tool
The execute_javascript tool is opt-in and disabled unless you explicitly enable it: