Skip to content

Add amazon/order-history domain skill - #534

Open
sfox100 wants to merge 2 commits into
browser-use:mainfrom
sfox100:amazon-order-history-skill
Open

Add amazon/order-history domain skill#534
sfox100 wants to merge 2 commits into
browser-use:mainfrom
sfox100:amazon-order-history-skill

Conversation

@sfox100

@sfox100 sfox100 commented Jul 17, 2026

Copy link
Copy Markdown

Adds a domain skill for extracting full order history from a logged-in Amazon session, field-tested against amazon.co.uk (2026-07-16) on a 2010-2026 account (1,007 orders).

Covers:

  • Auth detection (signin redirect) and the one-time headed login pattern
  • The timeFilter=year-YYYY + startIndex URL scheme, reading valid filter values from the #time-filter dropdown
  • .order-card extraction JS for titles + order dates
  • Traps: recent years (2024+) render a React layout with zero .order-card nodes (empty results are not "no orders"), late hydration needs a ~2s settle, and long multi-year scrapes should checkpoint to disk with flushed prints

🤖 Generated with Claude Code


Summary by cubic

Adds agent-workspace/domain-skills/amazon/order-history.md, a domain skill for extracting full Amazon order history from a logged-in session. Field-tested on amazon.co.uk (2010–2026, 1,007 orders) and amazon.com; runs now self-verify per-year counts.

  • New Features

    • Auth detection via redirect to /ap/signin; one-time headed login reused.
    • Navigation: new_tab() for the first visit, then goto_url(); read #time-filter values; paginate with startIndex=0,10,....
    • Self-verifying runs: read expected count from .num-orders, use .a-pagination .a-last for the real end, assert collected vs expected.
    • Extraction: .order-card parsing for titles and order dates; json.loads around JSON.stringify; date regex supports UK and US formats.
    • Gotchas: wait ~2s for hydration; checkpoint long runs; don’t trust empty pages.
  • Bug Fixes

    • Moved the file to agent-workspace/domain-skills/amazon/ so the harness loads it.
    • Removed the incorrect “2024+ React layout has no .order-card” note after re-testing; the count assertion guards against under-rendering.

Written for commit 734a31f. Summary will update on new commits.

Review in cubic

Field-tested pattern for extracting full order history from a logged-in
Amazon session: timeFilter/startIndex URL scheme, .order-card extraction
JS, and the traps (2024+ React layout returns no .order-card nodes, late
hydration, buffered-stdout loss on long scrapes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread domain-skills/amazon/order-history.md Outdated
Comment thread domain-skills/amazon/order-history.md Outdated
Comment thread domain-skills/amazon/order-history.md Outdated
Comment thread domain-skills/amazon/order-history.md Outdated
Addresses the review findings, plus a path bug the review did not catch:
the file was added at a new top-level domain-skills/, so the harness (which
reads $BH_AGENT_WORKSPACE/domain-skills/<host>/) would never have loaded it.
It now sits beside amazon/product-search.md.

- new_tab() for the first visit, goto_url() after, matching product-search.md
  (goto() was a local alias and would have raised NameError)
- json.loads() around the JSON.stringify payload so the result is a list
- date regex accepts "31 December 2024" and "December 31, 2024", so the
  documented .com support no longer yields empty dates
- replace the stop-on-a-short-page rule with .num-orders as an expected count,
  .a-pagination .a-last for the real end, and an assertion that fails loudly on
  a short scrape

Also corrects the 2024+ "React layout" claim: re-testing on 2026-07-29 found
year-2010 through year-2026 all extract with .order-card, so the earlier
zero-card reading was a misdiagnosis, not a layout change. The count assertion
is what actually guards against it. Verified end-to-end on year-2026: 57
expected, 6 pages, 57 collected, all dated.

Co-Authored-By: Claude <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="agent-workspace/domain-skills/amazon/order-history.md">

<violation number="1" location="agent-workspace/domain-skills/amazon/order-history.md:50">
P1: A missing `.num-orders` element is currently treated as a legitimate zero-order year: `count_text or "0"` makes the later `len(collected) != expected` check pass for an empty scrape. That defeats the self-verification and can silently produce a trusted but empty result when Amazon has not rendered the page or changes the selector. Missing/invalid count text could instead fail explicitly (while handling an explicit “no orders” response as zero).</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

```python
import re
count_text = js("document.querySelector('.num-orders')?.innerText") # '186 orders' / '1 order'
expected = int(re.sub(r"[^\d]", "", count_text or "0") or 0)

@cubic-dev-ai cubic-dev-ai Bot Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: A missing .num-orders element is currently treated as a legitimate zero-order year: count_text or "0" makes the later len(collected) != expected check pass for an empty scrape. That defeats the self-verification and can silently produce a trusted but empty result when Amazon has not rendered the page or changes the selector. Missing/invalid count text could instead fail explicitly (while handling an explicit “no orders” response as zero).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent-workspace/domain-skills/amazon/order-history.md, line 50:

<comment>A missing `.num-orders` element is currently treated as a legitimate zero-order year: `count_text or "0"` makes the later `len(collected) != expected` check pass for an empty scrape. That defeats the self-verification and can silently produce a trusted but empty result when Amazon has not rendered the page or changes the selector. Missing/invalid count text could instead fail explicitly (while handling an explicit “no orders” response as zero).</comment>

<file context>
@@ -0,0 +1,111 @@
+```python
+import re
+count_text = js("document.querySelector('.num-orders')?.innerText")  # '186 orders' / '1 order'
+expected = int(re.sub(r"[^\d]", "", count_text or "0") or 0)
+```
+
</file context>
Fix with cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant