Heal a playbook¶
Canonical tool: occam_playbook_heal
When a transcode fails on a hard site with no recipe: capture the page's DOM skeleton plus selector
candidates and an optional mechanical draftPlaybookJson stub (selectors only — not LLM-written).
Review the stub → lint → occam_playbook_save.
When to use¶
- After an
ok:falsetranscode whose failure response suggested it (agentHints.suggestedNext: "occam_playbook_heal"), typically onthin_extract. - Then: draft the recipe JSON →
occam_playbook_lint→occam_playbook_save. - Not for provable walls (captcha/login) — those are not healable by selectors.
Parameters¶
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
url |
string | — | yes | Absolute HTTP(S) URL to heal |
failure_reason |
string | — | yes | The prior failure.code from occam_transcode (e.g. thin_extract) |
session_profile |
string? | null | no | Same profile you used with the failing transcode |
max_skeleton_nodes |
int | 600 |
no | Max skeleton nodes (cap 600) |
Returns¶
Success envelope:
ok: true,url,failureReasondomSkeleton—{root, stats: {nodeCount, maxDepth, interactiveCount}}; each node is{tag, id?, class[]?, role?, testId?, aria?, text?, interactive, children[]?}anchors—{landmarks[], dataTestIds[], mainCandidates[]}; each candidate is{selector, textAnchor?, score}— the ranked guesses for the page's main content selector. Capture prefers content landmarks (main/article/#content) over nav chrome so a tightmax_skeleton_nodesbudget still surfaces usable candidates on docs SPAs.draftPlaybookJson?— mechanical schema_version 1 stub with topcontentSelectorsfrommainCandidates(omitted when empty). Review before save; not a verified playbook.agentHints—{suggestedNext, doNot[], maxVerifyRetries}
Failure envelope: ok: false, url, failureReason, failureCode, message, agentHints?.
Failure codes¶
heal_not_applicable (this failure isn't selector-healable), heal_failed, plus fetch-level codes
(timeout, network_error, captcha_or_challenge, …) when the capture itself could not load the
page. See failure codes.
Example¶
Call:
Trimmed response:
{
"ok": true,
"url": "https://spa.example/app/article/42",
"failureReason": "thin_extract",
"anchors": {
"landmarks": ["main", "article"],
"dataTestIds": ["article-body"],
"mainCandidates": [ { "selector": "[data-testid=article-body]", "textAnchor": "…", "score": 0.87 } ]
},
"agentHints": { "suggestedNext": "occam_playbook_save", "doNot": ["do not loop heal more than once per url per turn"], "maxVerifyRetries": 2 }
}
Related¶
- occam_playbook_lint — validate the recipe you draft
- occam_playbook_save — save + verify it
- Failure codes