Why generative UI needs real-time state

Generative UI needs real-time state because the model composing the screen can only respond to what its input says about the visitor. If that input was computed before the visit, the model assembles a confident, well-formed screen for someone who is no longer there. Real-time state, updated as the visitor acts, is what lets a generated interface follow the visit it is generated for.

By Alex DeanUpdated

Generative UI needs real-time state because the model or rules composing each screen can only respond to what the input says about the visitor. If that state was computed before the visit began, the interface is generated for who the visitor was, not for what they are doing now. The rest of this page covers what that state contains, how stale state fails, and the ways teams supply it.

The idea of generative UI itself is covered in what is generative UI. This page is about its input.

What state does a generative UI model read?

A model composing a screen reads a state object beside its component catalog. For a customer-facing page, that object usually has four parts.

  1. Session behavior. What the visitor has done in this visit: products viewed, searches run, filters applied, items added and removed, how long since the last action.
  2. Intent. A reading of what the session adds up to: comparing, price hunting, ready to buy, stuck. Sometimes the model infers it from the raw behavior; sometimes a separate step computes it first.
  3. Profile. What is known from before this visit: past orders, returns, a plan tier, a preference stated once. This changes slowly.
  4. Inventory and catalog. What is true about the things on the page: stock, price, delivery date, whether a promotion applies. This belongs to your own systems and changes on its own clock.

The first two change with every action the visitor takes. They are the parts most often stale, because they are the parts that did not exist when the last batch job ran.

What goes wrong when the state is stale?

A model does not know its input is old. It treats whatever it receives as the truth and composes a confident screen from it. Nothing errors. The page renders, the layout is valid, and it answers the wrong question. Some concrete cases:

  • The comparison that never appears. A shopper has opened four similar laptops in five minutes. The state still holds this morning’s empty session, so the model sees a cold visitor and leads with best sellers instead of a comparison table of the four they were weighing.
  • Reassurance for the wrong worry. A visitor has opened the returns policy twice and hovered on the size guide. A nightly segment calls them a loyal repeat buyer, so the model shows a loyalty upsell where fit details and free returns belong.
  • Promoting what is already in the basket. The visitor added the jacket ten minutes ago. The state lags, so the generated page puts the same jacket in its hero slot.
  • Selling what has sold out. Behavior is current but inventory is cached, so the model composes a slot around a size that is no longer in stock.
  • Repeating a failed path. A search returned nothing twice. The model, unaware, generates the same search-first layout a third time.

Each of these is a correct output for the input. That is why stale state is hard to catch: the model looks like it is working, and the cost shows up as conversion that never moves. When you log what was shown, log the state behind it and its age too, so a bad screen can be traced to a late input rather than blamed on the model.

How fresh does the state need to be?

Fresh enough that the visitor’s last action is in it by the next render. On a product page, the next render can follow the last click within a few seconds, so session behavior needs to update on that scale. A profile that changes weekly can be read from a daily job without loss. What is feature freshness explains how to measure this gap and why update time matters more than read time.

There are two numbers to ask any supplier for, each with its boundary: how long from an event arriving to the state reflecting it, and how long a read takes on the render path. A fast read of a stale value is still stale.

What are the ways to supply real-time state?

Five approaches come up. Most production systems combine two: a live source for session behavior and a slower one for profile.

Approach How fresh What you run Main tradeoff
Client-side context Current, but only for this tab Code in the browser that passes recent actions with the request No history, lost across devices and tabs, and the client can be tampered with
Warehouse batch As old as the last scheduled run SQL jobs and a sync to a cache or key-value store Cheap and familiar, but the current session is not in it
Your own stream processor Updated as events arrive, behind by processing time Event collection, Kafka, a stream job such as Apache Flink, a serving store, and on-call Full control, and you own windowing, late events, hot keys and the second year
A feature store’s online store As current as the job writing to it A feature store, plus the batch or stream pipeline that feeds it Built for ML features; most expect you to bring the stream. Feast push sources, for example, take values your pipeline computes
A managed real-time attribute service Updated as events arrive Event collection and definitions; the service computes and serves Less control over the engine, and a vendor relationship

Client-side context is a good first step. It shows whether live state changes the model’s choices before you build anything server-side. It stops being enough when the screen needs what the visitor did in an earlier session, or when the decision should not trust the browser.

Example: what a product page model reads

A clothing store composes its product page per visit. The model chooses what leads under the product photo: a comparison with similar items, fit details and reviews, or a delivery and returns panel. It reads three things about the session, plus profile and stock from other systems.

  • compared_products_session: the distinct products viewed this visit
  • size_guide_views_session: how often the size guide was opened
  • seconds_since_cart_change: how long since the basket last changed

Defined with the Snowplow Signals Python SDK, keyed on the session so the page asks about this visit:

from datetime import timedelta
from snowplow_signals import (
    Attribute, AtomicProperty, Criteria, Criterion, EntityProperty, Event, StreamAttributeGroup, domain_sessionid,
)

page_view = Event(name="page_view", vendor="com.snowplowanalytics.snowplow", version="1-0-0")
product_view = Event(name="product_view", vendor="com.example", version="1-0-0")
add_to_cart = Event(name="add_to_cart", vendor="com.example", version="1-0-0")
remove_from_cart = Event(name="remove_from_cart", vendor="com.example", version="1-0-0")

compared_products_session = Attribute(
    name="compared_products_session",
    type="string_list",
    events=[product_view],
    aggregation="unique_list",
    property=EntityProperty(vendor="com.example", name="product", major_version=1, path="id"),
    ttl=timedelta(hours=6),
)

size_guide_views_session = Attribute(
    name="size_guide_views_session",
    type="int32",
    events=[page_view],
    aggregation="counter",
    criteria=Criteria(all=[
        Criterion.like(AtomicProperty(name="page_url"), "%/size-guide%"),
    ]),
    ttl=timedelta(hours=6),
    default_value=0,
)

seconds_since_cart_change = Attribute(
    name="seconds_since_cart_change",
    type="double",
    events=[add_to_cart, remove_from_cart],
    aggregation="time_since_last",
    time_unit="s",
)

pdp_composer = StreamAttributeGroup(
    name="pdp_composer",
    version=1,
    attribute_key=domain_sessionid,
    owner="you@example.com",
    attributes=[compared_products_session, size_guide_views_session, seconds_since_cart_change],
)

The page reads the group on each render and places it in the state object beside the stock level from your catalog and any profile values:

session = sp_signals.get_service_attributes(
    name="pdp_composer",
    attribute_key="domain_sessionid",
    identifier=session_id,
)
# {"compared_products_session": ["jkt-210", "jkt-344", "jkt-118"], "size_guide_views_session": 2, ...}

With three products compared and two size guide visits, the model leads with fit details and a three-way comparison. With an empty list and no guide visits, it leads with photos and reviews. The catalog and the model are the same in both cases. Only the state differs. If the model is an agent, building generative UI with an AI agent covers how to keep its output inside your components.

Where Signals fits

Snowplow Signals is one option for the session half of that state. It collects behavioral events with its own SDKs, computes attributes like the ones above as events arrive, and serves them over an API or an MCP server. Deciding what to render stays in your rules or model, and stock stays in your catalog. The update and read figures, each with its boundary, are on real-time attributes. The result the visitor sees is an adaptive experience, and the generative UI topic covers the rest of the cluster.

See it on your own traffic

Add the SDK, define one attribute, and see an attribute updating against your own traffic in the first session. The free tier runs on the real engine: no card, no sales call.