Add CrawlDex preflight reporting example#2259
Conversation
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
|
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Code as User Script (runSubscriptionCancellation)
participant Reporter as CrawlDex Reporter (crawldex-report)
participant CrawlDex as CrawlDex API
participant Stagehand as Stagehand Runtime
Note over Code, Stagehand: CrawlDex Preflight and Reporting Example
Code->>Reporter: createReporter({reportUrl, agentKey})
Reporter-->>Code: reporter instance
alt crawldex: true
Code->>Reporter: preflight(site, task)
Reporter->>CrawlDex: Preflight request (site, task)
CrawlDex-->>Reporter: {verdict, warning}
Reporter-->>Code: preflight result
Note over Code: Fail‑open: always continue, never block
opt preflight.warning exists
Code->>Code: console.warn(preflight.warning)
end
opt verdict is "avoid_until_fresh_evidence" or "collect_evidence_first"
Code->>Code: console.warn("CrawlDex recommends caution")
end
Code->>Reporter: reportStagehandRun({reporter, stagehand, site, task, ...})
Reporter->>Stagehand: run({page, mark})
Stagehand->>Stagehand: goto, act("Open subscription settings")
Stagehand->>Reporter: mark("subscription_settings_visible")
Stagehand->>Stagehand: act("Start cancellation, stop before confirmation")
Stagehand->>Reporter: mark("cancel_flow_reached")
Stagehand-->>Reporter: {outcome, friction, evidenceSignals}
Note over Reporter: Build redacted report (no raw prompts, screenshots, page text)
Reporter->>CrawlDex: Submit report (redacted signals)
CrawlDex-->>Reporter: Ack
Reporter-->>Code: return value (outcome + metadata)
else crawldex: false
Code->>Stagehand: goto("https://example.com/account")
Stagehand->>Stagehand: act steps (no CrawlDex interaction)
Stagehand-->>Code: {outcome: "success_with_handoff"}
end
PR: Add opt-in CrawlDex preflight and redacted reporting example
Summary
This PR adds a Stagehand example for users who want to set
crawldex: true, preflight a web task against CrawlDex, and optionally submit a redacted outcome report after the run.Why
CrawlDex is a public reliability index for AI agents using websites. The current corpus has 2,354 accepted observations across 17 categories, with roughly 60% of common web tasks requiring a human handoff. Stagehand is a natural place to make that signal available before an agent acts.
What changes
packages/core/examples/integrations/crawldex-preflight-report.ts.createReporter(...),preflight(site, task), andreportStagehandRun(...).crawldex: trueis set by the caller.Safety
Test plan
git apply --check docs/integrations/stagehand.patchagainst Stagehand commit4ee8d99.npx --yes prettier@3.2.5 --check packages/core/examples/integrations/crawldex-preflight-report.ts.crawldex-report@0.1.0is live on npm and clean-imports the Stagehand adapter.Summary by cubic
Adds an opt‑in example that preflights Stagehand tasks with CrawlDex and optionally submits a redacted outcome report. It’s fail‑open and does not change production behavior.
packages/core/examples/integrations/crawldex-preflight-report.ts.createReporter(...),preflight(site, task), andreportStagehandRun(...)fromcrawldex-report.crawldex: true; warnings are logged and never block runs.Written for commit a16890e. Summary will update on new commits.