goBack
The go_back tool: one step back in the browser's history, like the Back button.
The go_back tool: one step back in the browser’s history, like the Back button. Reach for it so an agent can undo a navigation. With the Navigation API it says where that is, and it refuses when there is nowhere to go back to on this site.
Import
import { goBack } from "@webmcp-agents/tools";
import type { GoBackOptions } from "@webmcp-agents/tools";
Example
import { goBack } from "@webmcp-agents/tools";
export const tools = {
goBack: goBack(),
};
export async function back(): Promise<string> {
// "Went back to /products?color=blue."
return tools.goBack.invoke();
}
Input
Parameters
None: the tool takes no input.
Options
goBack(options?) takes a GoBackOptions, which is the options every common tool takes.
| Name | Type | Default | Description |
|---|---|---|---|
id |
string |
"go_back" |
The tool’s name (a-z A-Z 0-9 _ . -, 1 to 128). |
description |
string |
says to use it for “go back”, and that get_page tells you where you land |
What the agent reads to decide when to call it. |
Answer
A sentence (string): Went back to /products?color=blue. (the previous entry’s path, query and hash, or the full URL when it is on another origin), or Went back one page. when the browser cannot say where.
With no previous page (navigation.canGoBack is false, or, without the Navigation API, history.length is 1) it fails with unavailable: There is no previous page to go back to in this tab.
Notes
- It calls
history.back(), so any client router sees an ordinary back navigation, and a tool with amatchturns off as the path changes. - The tool has no flags and no control, so it runs unseen.
See also
- Common tools, the page that teaches it
goToandgetPagedefineWebTool