Infer user intent states from behavioral event streams
Project description
Istari
Istari is a Python library that infers user intent states from raw behavioral event streams and exposes them as a structured, machine-readable layer for CRO systems, personalization engines, and agentic AI workflows.
Instead of treating user behavior as isolated events or funnels, Istari models sessions as continuous intent trajectories over time.
What Problem Istari Solves
Modern products collect events like:
- page views
- scroll depth
- clicks
- add to cart
- remove from cart
- time gaps
- navigation loops
- rage clicks (Clarity)
- dead clicks (Clarity)
But downstream systems still reason in crude terms like funnels and conversion rates.
Istari sits between raw analytics and decision-making systems and answers:
- What is the user trying to do right now?
- Are they exploring, comparing, hesitating, or ready to act?
- What friction or uncertainty is blocking progress?
- How intent is evolving over the session?
Core Abstraction
Istari introduces a first-class abstraction called an Intent State.
An intent state is:
- time-aware: associated with timestamps
- probabilistic: has confidence scores
- explainable: includes attribution data
- composable: can be combined across domains
Example intent states:
browsingevaluating_optionsprice_sensitivetrust_seekingpurchase_readyabandonment_risk
High-Level Flow
- Raw events are normalized into a canonical schema
- Temporal patterns and transitions are extracted
- Intent hypotheses are scored
- A state machine produces the most likely intent trajectory
- Outputs are exposed to CRO rules or agentic systems
Design Goals
- Python-first, backend friendly
- Deterministic core with optional ML layers
- Explainability by default
- Domain-adaptable without retraining
- Open-core friendly architecture
Installation
pip install istari-core
For development:
git clone https://github.com/istari/istari.git
cd istari
pip install -e .
Quick Start
from datetime import datetime, timedelta, timezone
from istari.core.events import Event
from istari.core.session import Session
from istari.inference.rules import RuleBasedInference
from istari.inference.heuristics import BrowsingRule, PurchaseReadyRule
# Create a session
session = Session(
session_id="session_123",
user_id="user_456",
started_at=datetime.now(timezone.utc),
)
# Add events
session.add_event(Event(
event_type="page_view",
timestamp=datetime.now(timezone.utc),
user_id="user_456",
session_id="session_123",
properties={"page": "/products"},
))
# Infer intent state
inference = RuleBasedInference()
inference.add_rule(BrowsingRule())
inference.add_rule(PurchaseReadyRule())
intent_state = inference.infer(session)
print(f"Intent: {intent_state.state_type}")
print(f"Confidence: {intent_state.confidence:.2%}")
Microsoft Clarity Integration
Istari includes first-class support for Microsoft Clarity behavioral signals. Clarity events are converted into Istari's canonical format and mapped to intent signals:
from istari.sources.clarity import ClaritySource
# Initialize Clarity source
clarity_source = ClaritySource()
# Parse Clarity events/exports
clarity_events = [
{
"event": "rage_click",
"timestamp": 1234567890000,
"userId": "user_123",
"sessionId": "session_456",
"clickCount": 5,
},
# ... more events
]
# Parse and extract signals
events, signals = clarity_source.process(clarity_events)
# Signals are automatically mapped:
# - rage_click → friction.high
# - dead_click → intent.confusion
# - scroll → content_engagement
# - excessive_hover → hesitation
Clarity Signal Mappings
| Clarity Signal | Istari Signal | Intent Impact |
|---|---|---|
| Rage clicks | friction.high |
Contributes to abandonment_risk |
| Dead clicks | intent.confusion |
Contributes to hesitating |
| Scroll depth | content_engagement |
Contributes to browsing |
| Quick back nav | dissatisfaction |
Contributes to abandonment_risk |
| Excessive hover | hesitation |
Contributes to hesitating |
Architecture
Core Modules
core/: Event normalization, session modeling, intent states, transitions, scoringschemas/: Event schema normalization (base, ecommerce, web)inference/: Rule-based inference, heuristics, state machine, confidence calculationsignals/: Signal extraction (dwell, navigation, comparison, friction, price)explainability/: Attribution calculation, narrative generation, summariesplugins/: Plugin system for extending inference capabilitiessources/: Event source integrations (Clarity, etc.)integrations/: Analytics platform integrations (Mixpanel, Amplitude, Segment)
Event Sources vs Integrations
sources/: Behavioral signal sources (like Clarity) that provide frontend behavioral dataintegrations/: Analytics platform integrations for event ingestion
Open-Source vs Proprietary
Open-source core:
- Event normalization
- Session modeling
- Intent state definitions
- Rule-based inference
- Explainability primitives
- Plugin interfaces
- Clarity integration
Proprietary extensions (planned):
- Learned intent models
- Vertical-specific heuristics
- Advanced uncertainty modeling
- Real-time streaming inference
- Deep analytics integrations
Examples
See the examples/ directory for:
basic_inference.py: Basic intent inferenceecommerce_session.py: Full e-commerce session analysisexplain_intent.py: Intent explanation and narrativesclarity_integration.py: Microsoft Clarity integration example
Documentation
License
Apache License 2.0 - see LICENSE file for details.
Contributing
Contributions welcome! Please see our contributing guidelines (coming soon).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file istari_core-0.1.1.tar.gz.
File metadata
- Download URL: istari_core-0.1.1.tar.gz
- Upload date:
- Size: 40.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbcc928c0e3907b377954f4b203401b97246f5f16261a72bb4e8875967056f6f
|
|
| MD5 |
0bdccbdb5e3e36476b4ed0bdc5271a0f
|
|
| BLAKE2b-256 |
9258340c560c7e0a34f56317888b3c4161ef3fdea0d421cb5ffae7cf6d17b94e
|
File details
Details for the file istari_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: istari_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 57.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a676685e68ed1d079f8af260f38572afcf8dfd28d1b86f997309a7ff6bac9c8b
|
|
| MD5 |
cc6a4f72e1b832d78584f0e570282c90
|
|
| BLAKE2b-256 |
b96db3abefd6c0179254ea2ae77c1800cab6c3f9b0aca34d5768cd9281bc147b
|