Skip to content

Commit 8b5ec4d

Browse files
authored
More robust pagination (#21)
1 parent d6b3537 commit 8b5ec4d

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

scripts/test-pagination-local.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@ const agent = new BrowserAgent({
1717

1818
(async () => {
1919
const page = await agent.newPage();
20-
await page.goto("https://www.loblaws.ca/en/food/bakery/bread/c/28251");
20+
21+
await page.setViewportSize({ width: 1280, height: 1024 });
22+
23+
await page.route("**/*", (route, request) => {
24+
const resourceType = request.resourceType();
25+
if (["image", "video", "media", "font"].includes(resourceType)) {
26+
route.abort();
27+
} else {
28+
route.continue();
29+
}
30+
});
31+
32+
await page.goto("https://news.ycombinator.com/");
2133
try {
2234
await page.waitForLoadState("networkidle", { timeout: 10000 });
2335
} catch {
@@ -29,8 +41,9 @@ const agent = new BrowserAgent({
2941
console.log("Run extraction for page 1");
3042
let nextPageNumber = 2;
3143
let hasNextPage = true;
44+
const maxPage = 3;
3245

33-
while (hasNextPage) {
46+
while (hasNextPage && nextPageNumber <= maxPage) {
3447
const result = await page.ai(
3548
`Go to page ${nextPageNumber} of the results. If page ${nextPageNumber} does not exist, return early and complete the task.`,
3649
{

src/agent/actions/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const DEFAULT_ACTIONS = [
4141
ScrollActionDefinition,
4242
InputTextActionDefinition,
4343
KeyPressActionDefinition,
44-
ThinkingActionDefinition,
44+
// --- Disable for now - saw issues with invalid structured output because of this action
45+
// ThinkingActionDefinition,
4546
];
4647

4748
if (process.env.GEMINI_API_KEY) {

0 commit comments

Comments
 (0)