asgard-ai-platform/algo-rec-session
Implement session-based recommendation from short-term user behavior sequences without long-term profiles. Use this skill when the user needs to recommend in anonymous sessions, predict next click from browsing sequence, or build recommendations for non-logged-in users — even if they say 'what should they click next', 'anonymous user recommendations', or 'browsing sequence prediction'.
npx skills add https://github.com/asgard-ai-platform/skills --skill algo-rec-session
Session-based recommendation predicts the next item a user will interact with based on their current session's click/view sequence, without relying on long-term user profiles. Uses Markov chains, association rules, or neural approaches (GRU4Rec). Operates in real-time with O(sequence_length) inference.
Trigger conditions:
When NOT to use:
IRON LAW: First Few Clicks Are Disproportionately Important
Session-based methods operate WITHOUT long-term profiles. Intent must
be inferred from SHORT sequences. The first 2-3 clicks establish the
session's intent — misreading early signals derails the entire session.
Parse clickstream into sessions (by session ID or timeout-based splitting, typically 30min inactivity). Filter sessions below minimum length (3+ events).
Gate: Sessions parsed, minimum length threshold applied.
Markov Chain approach:
Association Rules approach:
Evaluate with leave-one-out: hide last item in each session, predict, check hit rate and MRR (Mean Reciprocal Rank).
Gate: Hit@20 significantly above random baseline.
Return ranked next-item predictions with confidence scores.
{
"predictions": [{"item_id": "789", "score": 0.65, "based_on": "last_3_clicks"}],
"session": {"length": 5, "items_viewed": ["a", "b", "c", "d", "e"]},
"metadata": {"method": "markov_order2", "hit_rate_at_20": 0.35}
}
Input: Session: [shoes_page, running_shoes, nike_air_max]
Expected: Recommend: nike_air_zoom (0.72), adidas_ultraboost (0.58), shoe_size_guide (0.41)
| Input | Expected | Why |
|-------|----------|-----|
| Session length = 1 | Popularity fallback | Single click insufficient for sequence pattern |
| Repeated item views | Weight recency, not count | User may be comparing, not broadening |
| Session intent shift | Adapt to latest clicks | User changed their goal mid-session |
references/gru4rec.mdreferences/session-splitting.mdTake asgard-ai-platform/algo-rec-session from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.