Harness 2: executing agent code as it streams
Framer rebuilt its agent harness to execute streaming JavaScript in cells, speeding up canvas edits by 20 percent while cutting task costs by up to 33 percent.
By Dillip Chowdary • Nov 07, 2026 • Source: framer.com

At a glance
- Product
- Framer Harness 2, an AI agent runtime overhaul
- Cost
- Up to 33 percent cheaper on benchmarked design operations
- Speed
- Up to 20 percent faster on benchmarked design operations
- Tool steps
- Cut in half (2x fewer)
- Cached input
- Down 39 percent per message on average
- Quality
- No measured drop in output quality
In this post
Framer launched Harness 2, an overhaul of its AI agent runtime that executes streamed JavaScript code while an underlying language model is actively generating it, according to framer.com's report. The re-engineered architecture allows the Framer Agent to handle entire design workflows in a single program rather than orchestrating iterative model turns.
Across benchmarked design operations, the company observed that the updated system is up to 33 percent cheaper and runs up to 20 percent faster. The redesign also cuts tool execution steps in half while slashing cached input tokens by an average of 39 percent per message, all achieved without any measured drop in output quality.
This technical breakdown examines the mechanics of Framer’s streaming execution pipeline, its structured document tree interface, and the token cancellation systems that govern agent evaluation. It is written for web engineers, systems architects, and technical product teams building agentic execution environments who require responsive client-side feedback during sustained generative tasks. By shifting away from isolated write commands to unified programmatic evaluation, Framer establishes a concrete pattern for real-time model interaction within complex web applications.
01What actually changed
Framer replaced its previous domain-specific language architecture with a general-purpose JavaScript execution model capable of handling full loops, conditional logic, and direct document querying. Previously, the agent expressed writes to Framer's document tree through a rigid DSL where the model sequentially emitted isolated commands to create nodes and assign properties.
While that legacy system delivered immediate visual feedback, it struggled during repetitive edits, requiring up to 100 separate editing commands just to change a property across 100 frames. Dependent operations, such as reading an existing style value to update a separate component, previously required round trips back to the model that repeatedly replayed contextual tokens.
The new system compiles arriving JavaScript into distinct executable units, enabling complex workflows such as finding and updating all occurrences of a legacy brand color across thousands of nodes within a single prompt. Instead of returning to the model for each intermediate inspection and decision, the agent writes native code that queries the document, checks matching conditions, and issues batch updates directly.
The harness transforms multi-step sequences, like verifying changes, staging an update, and publishing to production, into a continuous script. By collapsing disparate read-write cycles, the architecture reduces total tool steps by 2x and cuts cached input tokens by 39 percent.
02How it works
The execution pipeline parses incoming code streams into complete JavaScript statements, groups those statements into executable cells, and dispatches them sequentially to a dedicated Web Worker. Cells execute in order as classic scripts while preserving variable bindings across consecutive executions.
To maintain compatibility with classic script environments, Framer transpiles top-level await syntax on the fly. The parser also intercepts structured comments like step markers, converting annotations such as double slash at step Building buttons into emit calls that post live progress indicators to users while long-running operations execute.
Document interactions now use native programmatic method calls like tree.get, tree.insert, and tree.patch rather than legacy DSL commands. A script can query a specific button node reference, loop through a tree walk iterator, and clamp opacity values across hundreds of elements to match that target button directly from live document data.
Because values are read and written locally within the Worker runtime, the model no longer needs to ingest property values back into its prompt context before echoing them out into subsequent write operations. Valid document mutations take effect immediately, allowing canvas updates to render before the model finishes producing its remaining code.
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
03Why it matters
In standard programmatic agents, executing code only after the full text arrives creates two critical bottlenecks: delayed visual feedback and wasted token expenditure. When systems buffer an entire program before running it, users must wait for token generation to conclude before observing any canvas changes. More importantly, if a script encounters an early return condition or throws an unexpected runtime error within its opening lines, all subsequent tokens generated by the model are wasted, racking up unnecessary generation latency and billed output-token charges on unexecuted code.
If an early check discovers that a required button node is missing, the script returns early or raises a targeted exception. The harness intercepts this termination, stops the active stream, and discards in-flight generation tokens immediately. This early cancellation saves significant output token costs, preserves changes that were already validly committed to the document tree, and provides actionable error payloads that guide the agent’s subsequent attempt.
If an early check discovers that a required button node is missing, the script returns early or raises a targeted exception. The harness intercepts this termination, stops the active stream, and discards in-flight generation tokens immediately. This early cancellation saves significant output token costs, preserves changes that were already validly committed to the document tree, and provides actionable error payloads that guide the agent’s subsequent attempt.
04Who is affected
Software engineers building browser-based agent harnesses, interactive design platforms, and developer tooling stand to gain actionable architectural blueprints from this shift. Teams managing agentic products currently face difficult trade-offs between interactive responsiveness and expressive programming power.
Framer’s implementation demonstrates that applications do not have to settle for simplistic, step-by-step tool calling to preserve real-time visual streaming. By pairing AST stream parsing with isolated Web Worker execution, platforms can grant generative models access to full scripting capabilities without sacrificing immediate interface updates.
Product designers and web editors using the Framer canvas experience more responsive manipulation when delegating large-scale maintenance tasks. Rather than waiting through multiple pauses as an agent repeatedly inspects properties, queries state, and resubmits prompts, end users observe visual canvas modifications commencing almost immediately after generation starts. Even when a single program alters hundreds of styles or moves elements through multi-stage publishing checks, the streaming cell architecture displays progress incrementally, transforming brittle single-property edits into smooth, end-to-end automations.
05What to watch
The broader implementation of streaming code execution points toward wider industry adoption of AST-based evaluation models across multiple languages. Framer cited related research including Executing as You Generate, which applies AST-driven eager execution concepts to Python environments. As generative models assume responsibility for larger operational batches, runtime harnesses across browser and server contexts will increasingly integrate streaming syntax validation, partial cell compilation, and speculative execution controls to compress user latency and prevent token overruns on failing operations.
Subsequent developments in this domain will center on refining error recovery strategies and granular state management within live documents. While early cancellation successfully catches invalid baseline assumptions, maintaining document consistency requires harnesses to isolate recoverable write exceptions from fatal script terminations. Monitoring how agent frameworks design actionable error messages that teach models to self-correct during subsequent streams will reveal how effectively browser platforms can support complex, self-healing programmatic workflows without manual developer intervention.
Frequently asked questions
How does Framer Harness 2 execute JavaScript before code generation is complete?
The harness uses an AST parser to detect complete JavaScript statements within the incoming stream, batches them into executable cells, and executes them sequentially inside a dedicated Web Worker while preserving variable bindings.
What performance gains does Framer report for Harness 2?
Framer reported that Harness 2 is up to 33 percent cheaper and 20 percent faster, while reducing tool steps by 2x and lowering cached input tokens by an average of 39 percent per message.
How does early cancellation reduce agent token costs?
When an early check encounters a missing element or throws an error, the execution system stops the stream immediately, preventing further generation and eliminating billed output token costs on code that would never run.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Advertisement