build AI that knows what your users just did

Turn session behaviour into live context your agent can read at any point, and subscribe to the cues that tell it when to act. Its replies stay connected to what the user just did, and land at the right moment.

[integrates with]
  • Segment
  • Google Analytics
  • Mixpanel
“Customers don't resent AI. They resent wasted effort. When AI loops, blocks access to a human, or forces people to repeat themselves, trust erodes.”

Gladly + Wakefield Research, 2026

[section: runtime]

your agent steps in before the user asks

session
waxed field jacket£189.00
event_log · live
+0.6sadd_to_cartfield-jacket
+0.9sadd_to_cartfield-jacket
+1.1sadd_to_cartfield-jacket
+1.2srage_click ×3#add-to-cart
subscribe(e => e.name === 'rage_click', reachOut)
+0.9sadd_to_cartfield-jacket
+1.1sadd_to_cartfield-jacket
+1.2srage_click ×3#add-to-cart
reachOut() fired
context handed to your handler
{
  event_log: [
    { name: "add_to_cart", elapsed_s: 1 },
    { name: "rage_click", selector: "#add-to-cart", count: 3 },
    { name: "scroll", depthPct: 78 }
  ],
  marketing_params: { utm_source: "organic" }
}
most agentswait for the user to give up and leave.
your agent · first move

Hi there! Looks like the add to cart button isn't responding. That usually means the session expired. Want me to refresh your cart and add the field jacket for you?

our thesis

your agent only sees the last thing the user typed

Prior session context is missing
Typical agents see what the user typed, but not the hesitation, option navigation, retries, rage-clicks or dead-ends that happened before.
The signal already exists
You already track it for dashboards and warehouses. We turn that same signal into real-time context for your agent.
And now it matters
Agents are the first software that can act on it in the moment it matters, opening the conversation themselves instead of reading it back from a dashboard the next day.
your app (client-side)
your tracking layer
Segment
Google Analytics
Mixpanel
contextune
your agent stack
OpenAI
Anthropic
Vercel AI
LangChain
[section: use-cases]

who this is for

contextune works best for customer-facing AI agents inside an existing UI. It reads what a real person is doing in the browser, so it earns its keep wherever a human is on the other side of the agent.

travel agents

Hi! How can I help you today?

You’ve opened this hotel twice and checked the reviews both times. The thing most guests mention is noise from the street. Want me to find quieter alternatives nearby?

ecommerce agents

Welcome! What brings you here?

Hi - it seems your cart may have expired while you were checking out. Want me to restore it and keep the same items?

support agents

Hello, how may I assist you?

Looks like the payment went through, but the confirmation page didn’t load. Would you like me to check whether the order was created?

copilots / in-product agents

Hi there! What can I do for you?

You’ve switched back to the Retention dashboard three times this week without changing the date range. Want me to show what moved for that segment since your last visit?

how it works

install once, nothing to run

Read the quickstart →
  1. Initialize the SDK

    Call init() with your analytics source (GA4, Segment, or Mixpanel) and the snapshot fills from events you already send. Runs entirely in the browser, no collector to deploy.

  2. Read it, or react to it

    Pull a snapshot when your agent replies, or subscribe to a cue and push the moment it lands. Same profile, your call on the timing.

  3. Inject into your agent prompt

    Drop the snapshot into your system prompt. Your agent now sees what the user was doing.

[example]
import { Contextune } from '@contextune/sdk'

// Initialize — tap your existing analytics stream
Contextune.init({ source: 'ga4' }) // or 'segment' | 'mixpanel'

// Pull: read a snapshot whenever your agent replies
const snapshot = Contextune.getSnapshot()

// Push: or fire the moment a cue lands
Contextune.subscribe(e => e.name === 'rage_click', reachOut)

// Inject into your system prompt
const systemPrompt = `
You are a helpful shopping assistant.

Live behavioral context:
${JSON.stringify(snapshot, null, 2)}

Use this context to understand the user's intent.
`
[section: benefits]

zero latency

It runs client-side with no round trip. getSnapshot() is a synchronous read from in-memory state, sub-millisecond on a populated engine.

Nothing leaves the browser when you read the snapshot. The behavioural profile is maintained in the user's session, and you inject it into the system prompt at the moment you call your model. There is no collector hop and no network round trip between the behaviour and the decision.

snapshot read
< 1ms
round trips
0
servers to provision
0

open source

MIT-licensed, with no account to create and nothing metered. Drop it into your own app and keep the data where it already lives.

Today it runs entirely in your application, with nothing to provision and nothing to bill. The hosted state layer is the paid product later; you opt in when you need it. Until then the integration is an install and one call to init().

resolve harder user scenarios

In an open benchmark, the same agent solved 15 of 16 tasks when it could read the user's behaviour, and 5 of 16 when it could only see the current page.

We held the model fixed and changed only what it could see: the full behavioural snapshot, the current page alone, or nothing. The behavioural agent answered the tasks that depend on what the user did over time, the ones a page-aware agent has no way to reach.

[section: faq]

common questions

01does my data leave the browser?

No. Zero network egress from the SDK itself. The behavioural profile is built and maintained in memory in the user's session, and getSnapshot() is a synchronous read with no fetch and no beacon.

If you bring your own event source (Segment, GA4), that source will keep making its own network calls. The contextune SDK does not.

02how does it work with my existing analytics?

It intercepts, it doesn't replace. Point the SDK at your existing source (source: 'ga4', 'segment', or 'mixpanel') and it taps that provider's traffic, normalises the events you're already firing, and folds them into the snapshot.

Your dashboards keep working. The agent gets the same cues, structured.

03what about CSP?

The SDK is a bundled dependency, not a remote script. It doesn't inject <script> tags or make cross-origin requests of its own, so strict CSPs pass.

If you've wired in an external event source, allow that source's domain in your CSP. That part isn't ours.

04do you support react native or mobile?

Not yet. The capture surface depends on browser-only APIs such as visibilitychange and AbortController. A React Native build would be a separate target with a different cue set.

Mobile web works the same as desktop web. If you're shipping a PWA, you're covered today.

05how big is the bundle?

~13KB minified, ~4–5KB gzipped. No peer dependencies. The ESM build tree-shakes, so source plugins you don't use don't ship.

A typical snapshot in the prompt runs 1–3KB of JSON. Configurable per block, and you can serialise it as TOON ↗ instead for fewer tokens if you're token-sensitive.

06browser compatibility?

Any evergreen browser. The SDK needs fetch, sendBeacon, and XMLHttpRequest; each capture patch is installed only when its API is present and skipped when it isn't.

Older browsers fail silently. Your app keeps working and the snapshot is just empty.