Overview
The snapshot pipeline performs four key steps:- Mark elements - Identify interactive, hidden, and scrollable elements at runtime
- Serialize HTML - Capture the current page structure
- Clean HTML - Apply mode-specific cleaning rules to remove noise
- Assign counters - Add
cattributes to retained elements for addressing
All snapshot modes return compact, LLM-friendly HTML strings optimized for token efficiency.
Snapshot Modes
OpenSteer provides five snapshot modes, each optimized for different scenarios:action
Balanced context for action planning and element interaction.
- Interactive elements (buttons, links, inputs)
- Semantic structure (headings, sections)
- Navigation elements
- Forms and form controls
- Scripts and styles
- Hidden elements
- Decorative content
- Non-interactive containers
- Before
click,input,hover,selectactions - For AI agents planning next steps
- When you need element counters for targeting
extraction
Richer content for data extraction tasks.
- Text content and structured data
- Tables and lists
- Images with alt text
- Article content
- Product information
- Scripts and styles
- Navigation clutter
- Ads and promotional content
- Non-content containers
- Before
extractcalls - For scraping structured data
- When content matters more than interactivity
clickable
Clickable elements only, minimal context.
- Buttons
- Links (
<a>tags) - Clickable inputs
- Interactive elements with click handlers
- All non-clickable elements
- Static text
- Structural containers
- For click-only AI agents
- To minimize token usage
- When page context is unnecessary
scrollable
Scrollable containers only.
- Elements with
overflow: scrolloroverflow: auto - Scrollable containers
- Elements with scroll behavior
- Non-scrollable elements
- Static content
- Before
scrollactions - For infinite scroll implementations
- When identifying scrollable regions
full
Broad HTML with minimal cleaning.
- Complete page structure
- All visible elements
- Maximum context
- Scripts (for security)
- Inline styles (for brevity)
- Some non-semantic noise
- For comprehensive page analysis
- When you need complete DOM context
- For debugging and inspection
Snapshot Options
withCounters
Controls whether element counters are assigned and synchronized with the live DOM.
Counter values (
c attributes) are assigned fresh on every snapshot. They are synchronized between the snapshot HTML and live DOM nodes.markInteractive
Controls whether interactive elements are marked with special attributes during runtime analysis.
- Clickable elements
- Focusable elements
- Form controls
- Links and buttons
Counter Semantics
Element counters (c attributes) enable precise element addressing:
Counter Assignment
Counter Resolution
Special Cases
Boundary wrappers likeos-iframe-root and os-shadow-root may be unnumbered:
- Inaccessible iframes (cross-origin without CORS)
- Closed shadow roots
HTML Cleaning and Optimization
The cleaning pipeline optimizes HTML for LLM consumption:Removed Elements
<script>tags (all modes)<style>tags (all modes)- Hidden elements (
display: none,visibility: hidden) - Empty containers with no interactive children
- Redundant wrapper
<div>elements
Optimized Attributes
- Removes
styleattributes (inline styles) - Preserves semantic attributes (
id,class,href,src) - Keeps
aria-*androleattributes - Adds
ccounters whenwithCounters: true
Whitespace Normalization
- Collapses multiple spaces into one
- Removes leading/trailing whitespace
- Preserves meaningful line breaks
Best Practices
Match snapshot mode to task
Match snapshot mode to task
Use
action before interactions, extraction before data retrieval, and clickable/scrollable/full for specialized needs.Take fresh snapshots before critical actions
Take fresh snapshots before critical actions
DOM state can change. Take a new snapshot before important interactions.
Use counters for precise targeting
Use counters for precise targeting
When you have a specific element counter from a snapshot, use it directly for faster resolution.
Consider token costs
Consider token costs
Larger snapshots consume more LLM tokens. Use minimal modes like
clickable when possible.Related
Selectors and Replay
Learn how selectors are resolved and persisted
Snapshot API
Complete API reference for snapshot() method