# remediation agent failed to patch aria-hidden focus violation - how to fix it

## TL;DR

Patch with the inert attribute, not tabindex surgery: the agent should add inert to the aria-hidden container's background content and remove aria-hidden from anything that must stay interactive. Failed patches usually fiddle with individual tabindex values and miss dynamically added children. One line of why: inert fixes the whole subtree at once, tabindex whack-a-mole misses the next render.

## The error, verbatim

```text
RemediationAgentError: patch failed for aria-hidden-focus
    tried: set tabindex=-1 on 12 known children
    still_failing: 4 children added by late hydration
    target: .modal-backdrop[aria-hidden=true]

```

## Fix it step by step

### Step 1: Reproduce the failed patch

```bash
node agent/remediate.js --rule aria-hidden-focus | rg -i 'fail|still' | head -5
```

Expected: The patch lands but the violation persists on late-added children.

### Step 2: Confirm the late children

```bash
npx @axe-core/cli https://example.com/ --rules aria-hidden-focus --save axe-h.json | tail -2
```

Expected: Fresh scan shows the violation on elements the patch missed.

### Step 3: Switch the patch to inert

```bash
rg -n 'tabindex|inert' agent/patches/aria-hidden-focus.js | head -10
```

Expected: Replace per-child tabindex edits with a single inert attribute on the container.

### Step 4: Re-run remediation

```bash
node agent/remediate.js --rule aria-hidden-focus | tail -4
```

Expected: Violation clears and stays clear across hydration.

### Step 5: Add a regression probe

```bash
node agent/run-audit.js --smoke | tail -3
```

Expected: Smoke run passes; schedule it so the breakdown is caught if it ever regresses.

## When to use this skill

- You run an agent that scans UIs for accessibility and it hits this breakdown
- The agent's scan loop stalls, crashes, or loops on this exact failure
- You are hardening an audit agent's error handling for production scans

## When NOT to use this skill

- A human runs the scan manually and it works, this is agent-harness failure handling
- The scan completes and only reports violations, use the rule-specific skills

## Compatibility

Remediation agent with DOM patch primitives. The inert attribute is supported in all modern browsers. Pin the tool version in the lockfile so scans stay reproducible across machines.

## Variant phrasings

### agent cannot fix aria-hidden focus

Same failure, same inert patch.

### remediation tabindex whack-a-mole

Practitioner phrasing for the failed approach.

### the breakdown hits other routes too

Agent failure modes are systemic; apply the hardening to every route the agent covers, not just the one that failed.

## Why it happens

Agents patch what they can see: the children present at patch time. Late hydration, portals, and dynamically injected content add focusable children after the patch, reopening the violation. Per-child tabindex edits are inherently racy. The inert attribute on the container is declarative and covers the whole subtree including future children, which is why it is the correct patch shape. The agent's patch library should prefer subtree-level fixes over node-level edits wherever the platform offers one. Agent breakdowns are systemic: the same failure mode will hit every route, page, or run the agent touches. Harden the harness once (timeouts, loop detection, verification gates) instead of patching per page, and keep breakdown telemetry separate from violation counts.

## Edge cases

- inert also blocks pointer events, which is correct for background content behind a modal.
- If the container must stay interactive, the patch is wrong, remove aria-hidden instead of adding inert.
- Verify across a hydration cycle, not just the initial render, before marking fixed.
- Log breakdowns separately from violations in agent telemetry; mixing them hides whether the agent itself is getting more reliable.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_O_bIvDGAsP-UOUL2s9tRSg
