Web
AuraScore 83/100

Autonomous Browser Session Recovery and State Machine

Architect a deterministic state machine and self-healing recovery framework for multi-step browser agent chains.

Use this template to design resilient state tracking, DOM mutation recovery, and loop prevention for web automation agents. It establishes unambiguous step verification, session checkpoints, and telemetry anchors.

Template

Role: Senior Automation and Resiliency Engineer specializing in autonomous browser state machines and fault-tolerant web workflows.

Context

  • Session lifecycle model: {{session_lifecycle_model}}
  • DOM mutation patterns: {{dom_mutation_patterns}}
  • Idempotency key strategy: {{idempotency_keys}}
  • Retry and backoff matrix: {{retry_backoff_matrix}}
  • Telemetry and event sink: {{telemetry_sink}}
  • Agent execution timeout budget: {{agent_execution_timeout}}

Task

Develop an autonomous browser session recovery and state machine framework that maintains transaction integrity, prevents cyclic agent stalls, and remediates volatile DOM failures across complex multi-step web task chains.

Method

  1. Define discrete finite states (Initialization, Navigation, Assertion, Mutation, Verification, Termination) adapted to {{session_lifecycle_model}}.
  2. Design a deterministic DOM snapshot and mutation-observer baseline to detect dynamic page shifts against {{dom_mutation_patterns}}.
  3. Establish an idempotency tracking mechanism using {{idempotency_keys}} to prevent duplicate form submissions or duplicate transactions upon recovery.
  4. Build an automated state verification engine that checks post-action DOM conditions before the agent advances to subsequent steps.
  5. Structure a cyclic-loop detector that triggers remediation if an agent repeats identical tool invocations without state progression.
  6. Map fallback execution paths using {{retry_backoff_matrix}} for transient elements, stale references, and network disconnections.
  7. Implement session snapshotting and state persistence logic that feeds structured diagnostic events into {{telemetry_sink}} within {{agent_execution_timeout}} limits.

Constraints

  • State transitions MUST require explicit assertion verifications and cannot rely on model inference alone.
  • Mutating web interactions MUST NOT execute more than once per unique key in {{idempotency_keys}}.
  • Recovery routines must terminate and yield gracefully if execution approaches {{agent_execution_timeout}}.
  • Session state data must remain strictly isolated from cross-tenant or unauthenticated browser contexts.

Output format

Structure the framework across four dedicated sections:

  1. State Transition Matrix (formal table containing Current State, Event, Transition Guard, Target State, and Fallback Action)
  2. DOM Verification & Stale Reference Protocol (explicit logic for handling dynamic hydration and layout shifts)
  3. Idempotency & Duplicate Action Barrier (step-by-step state checkpointing rules)
  4. Diagnostic Telemetry Schema (exact JSON event schemas sent to {{telemetry_sink}})

Self-review

  • Ensure every transient failure mode identified in {{dom_mutation_patterns}} has a deterministic recovery guard.
  • Verify that the idempotency rules strictly enforce zero duplicate mutations.
  • Confirm all state transitions have an absolute exit path before reaching {{agent_execution_timeout}}.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-web
autonomous-agents-workflows
state-machine
browser-agent
fault-tolerance