Widget page-context extraction — Pattern A (bake) + Pattern B (extract)
Date: 2026-05-21 · Status: Pattern A shipped for cockpit · Pattern B parked
The question Dan asked
“Given that it has context living within, how will it access that thinking, without spoon feeding it all”
The ask-opus widget mounts on a page. The page has rich content (analyst headline, money map, deadlines, actions on the cockpit). The widget by default passes ONLY a short data-context-hint to the Worker — Opus sees the label but not the data. Opus correctly refuses to invent priorities on an active claim. The data is RIGHT THERE on the page, but it’s not reaching Opus.
How to fix without spoon-feeding everything via author-written hints?
Two layered patterns
Pattern A — BAKE (build-time spoon-feed)
The render script knows the structured data already.
Pipe a compact summary of it into data-context-hint.
─────────────────────────────────────────────────────
sidecar.json + analyst.md (the data, structured)
│
▼
pa_claim_cockpit_render.py (the render script)
│
▼ builds build_claim_context_summary()
│ ~600 chars: identity + event + headline +
│ money map + top deadline + top 3 actions
▼
<div data-ask-opus
data-context-id="claim-046414618"
data-context-hint="<the 600-char summary>">
│
▼ widget reads the attribute, sends to Worker
▼ on every /api/ask call
│
Worker injects into system prompt → Opus sees facts
Pros: Cheap. Deterministic. Ships today. Uses existing widget API (no widget rebuild). One render script change.
Cons: Only as fresh as the last cockpit render. Author has to decide UPFRONT what’s contextually relevant (claim identity + money map vs. fine-grained details). Each new widget host needs its own render script to bake context.
Status: SHIPPED for cockpit 2026-05-21 (commit 02616cf). Cockpit now passes ~600 chars of structured facts on every Opus call.