fix(agent): fail tainted fallback-only steps with POLICY_DENIED
After a secret fill the attempt is pixel-tainted, so the runner withholds pixelFallback. An agent step that could only read the screen from that fallback screenshot never got it: it failed with the engine's operation timed out (ACTION_FAILED), and act spent two operation budgets doing so (the cache's opening probe swallowed the first timeout and the executor's first look timed out again).
retryingObserve(packages/e2e/src/agent/phases.ts) now owns thepixelFallbackdecision: callers say whether the step wants fallback (actand executor observations inobservation-feed.ts,vision: truejudgments ininvocation.ts), and the taint is read per capture. A capture whose fallback a secret fill withheld and that times out becomesPOLICY_DENIED, naming the fill. The step clock still wins: a capture cut short by the step deadline staysSTEP_TIMEOUT.- A
vision: falsejudgment never asks for fallback and keeps its timeout.vision: 'only'was already denied before any capture. - The step cache's opening probe (
step-cache.tscaptureStart) propagates that denial instead of treating it as a miss, soactfails after one operation budget. Later probes still hand off to the executor, and a denied start is not an eviction. - Docs:
reference/errors.mdx,reference/agent.mdx,security.mdx, and the skill's debugging table.
flowchart LR
A[semantic capture times out] --> B{step clock out?}
B -- yes --> T[STEP_TIMEOUT]
B -- no --> C{fallback wanted and secret filled?}
C -- yes --> P[POLICY_DENIED: a secret was filled]
C -- no --> E[engine error, as before]
Follow-up: #821 moves these tests to agent-fallback-handoff.test.ts and still asserts 'timed out' for the two tainted cases. Once this lands, tighten that assertion to POLICY_DENIED (the cubic thread on its line 393).
Verified
Ran it locally: yes
tests/integration/agent-semantic-fallback.test.tsnow assertsPOLICY_DENIEDfor both tainted cases, one observation for the taintedact, and a timeout for a tree-only judgment after a fill. On main it fails withexpected 'ACTION_FAILED' to be 'POLICY_DENIED'. Mutations checked: dropping the flag from the feed or from the judgment, setting it for tree-only judgments, or removing the opening-probe rethrow each fail it. Removing the guard-first order fails the new unit test inagent-phases.test.ts.- Built CLI, scratch project in
/tmpon@e2e-dev/web: a page whose main thread hangs after the password field's input event,actionTimeout: 3000, thenagent.act,agent.assert({ vision: true }), andagent.assert()afterfill(credentials.user('admin').password). The secret appears nowhere under.e2e/.
| step | main | this branch |
|---|---|---|
agent.act | ACTION_FAILED: operation timed out, 6.06s | POLICY_DENIED: agent.act could not read the semantic tree, and its screenshot fallback is denied: a secret was filled in this attempt, so no pixels leave the runner until it ends (PIXEL_TAINTED), 3.00s |
agent.assert vision: true | ACTION_FAILED: operation timed out, 3.00s | POLICY_DENIED: agent.assert could not read ... (PIXEL_TAINTED), 3.01s |
agent.assert tree-only | ACTION_FAILED: operation timed out, 3.00s | ACTION_FAILED: operation timed out, 3.00s |
A fresh-context review found three things, all fixed: the denial had overridden STEP_TIMEOUT at the deadline, the denying path had no unit test, and the JSDoc on begin() was stale.
web agent fails with REPLAY_STALE on main too (since chore: version packages (#774) moved the cache key); it is not from this change.