You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: prompt improvements, CLI Dockerfile, and sanitize AI generation logs
Prompt improvements (based on eval run analysis):
- Acknowledge dynamic pages that load content on scroll (remove false
"no scrolling needed" claim)
- Add guidance for click failures, autocomplete/combobox fields, date
pickers, stale element refs, and PDF-avoidance (use HTML versions)
- Fix bug: hasWebSearch was not passed to actionLoopSystemPromptTemplate,
so the webSearch tool instruction was never shown to the model
- Add step-error recovery guidance (stale refs, retrying with different
approach, no repeated actions)
- Refine abort() vs done(): only abort when core task fails; done() is
acceptable when supplementary details are inaccessible
- Require explicit criterion confirmation in done() answers
CLI Dockerfile (for eval/standalone use):
- Uses --ignore-scripts + pnpm rebuild esbuild to avoid prepare
lifecycle running before source is copied
- Installs Playwright system deps as root, browser as node user
- INSTALL_PLAYWRIGHT_BROWSERS ARG to skip browser install in CI/tests
- Stub config files for both root and node users
Strip binary image data from ai:generation logs by default:
- JSONConsoleLogger sanitizes image content blocks in AI_GENERATION
events (replaces raw bytes with { type, mediaType, size, data: '<omitted>' })
- Avoids 50-100MB stdout.txt files from embedded JPEG data
- Opt-out via sanitizeGenerationImages: false
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Copy file name to clipboardExpand all lines: packages/core/src/prompts.ts
+17-3Lines changed: 17 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ You adapt to situations and find creative ways to complete tasks without getting
122
122
123
123
IMPORTANT:
124
124
- You can see the entire page content through the accessibility tree snapshot.
125
-
- You do not need to scroll or click links to navigate within a page - all content is visibleto you.
125
+
- The accessibility tree shows all currently loaded page elements. On dynamic pages, some content may only appear after scrolling or interaction — if expected data isn't visible, try scrolling or interacting to trigger loading.
126
126
- Focus on the elements you need to interact with directly.
127
127
`.trim();
128
128
@@ -285,15 +285,21 @@ Analyze the current page state and determine your next action based on previous
285
285
- extract() if you need more information
286
286
287
287
**Best Practices:**
288
-
- Full page content is visible - no scrolling needed
288
+
- The accessibility tree shows currently loaded elements; dynamic pages may load more content on scroll
289
289
- Clear obstructing modals/popups first
290
290
- Prefer click() over goto() for page navigation
291
291
- Submit forms via enter() or submit button after filling
292
292
- Find alternative elements if primary ones aren't available
293
+
- When click() fails due to element interception, try focus() first, then keyboard navigation (Tab, Enter, arrow keys), or press Escape to dismiss overlapping overlays
294
+
- For autocomplete/combobox search fields (e.g., flight origin/destination, location pickers): after fill(), use focus() on a visible suggestion in the dropdown followed by enter() to select it — click() on autocomplete suggestions often times out
295
+
- For date pickers and calendar widgets: prefer typing dates directly into the date input field using fill() rather than clicking through calendar months; if the field doesn't respond to fill(), try focus() on it first; avoid repeated calendar navigation clicks — if clicking "next month" fails twice, try filling the date field directly or using keyboard input
296
+
- When you receive an 'Invalid element reference' error, the page DOM has changed — read the updated page snapshot on your next turn and use the new element refs; do not retry old ref IDs
293
297
- Adapt your approach based on what's actually available
294
298
- If you don't find relevant links or buttons, and the site has a search form, prioritize using it for navigation
295
-
- Use abort() only after trying reasonable alternatives (site down, access blocked, required data unavailable)
299
+
- If you have found the core information requested but cannot access supplementary details due to site limitations, use done() with what you have — only use abort() when the core task cannot be completed at all
296
300
- For research: Use extract() immediately when finding relevant data
301
+
- For academic papers or documents that require reading, counting, or extracting content (e.g., counting figures/tables, reading body text): PDFs are often unscrollable and unreadable — use webSearch to find an HTML version (e.g., ACL Anthology, Semantic Scholar) or the abstract page before attempting the PDF
302
+
{% if hasWebSearch %}- If you need to search the web, use webSearch({query}) directly rather than filling in a browser search engine (DuckDuckGo, Google, Bing, etc.) — webSearch avoids CAPTCHA and bot detection that will block browser-based searches{% endif %}
297
303
{% if hasGuardrails %}- Verify guardrail compliance before each action{% endif %}
298
304
299
305
**When using done():**
@@ -304,6 +310,7 @@ Provide your final answer:
304
310
- Include all requested information
305
311
- Format results as VALID Markdown
306
312
- NEVER return raw JSON - ALWAYS format structured data as VALID Markdown
313
+
- If the task required finding content that meets specific criteria (minimum rating, review count, price range, ingredient count, etc.), explicitly confirm each criterion was met in your answer
307
314
308
315
{% if hasGuardrails %}
309
316
🚨 **GUARDRAIL COMPLIANCE:** Any action violating the provided guardrails is FORBIDDEN.
CRITICAL: ALL TOOL CALLS MUST COMPLY WITH THE PROVIDED GUARDRAILS
429
437
{% endif %}
430
438
439
+
**Recovery guidance:**
440
+
- If the error mentions "Invalid element reference" or "does not exist on the current page": the page DOM has changed and your cached ref IDs are stale. Do NOT retry the same ref. Wait for the next page snapshot (it will arrive automatically) and use only the new ref IDs shown there.
441
+
- If an action keeps failing after 2 attempts, try a different approach: use a different element, navigate differently, or use extract() to re-read the current state.
442
+
- Do NOT repeat the same action with the same arguments.
Do not repeat your previous answer. Address the issues identified above.
528
+
If you cannot address the feedback due to genuine site limitations (disabled UI, inaccessible content), call done() with the best answer available rather than aborting.
0 commit comments