Skip to content

feat(agent-sessions): surface sessionless GenAI traces as single-trace sessions - #655

Merged
JeremyFunk merged 3 commits into
mainfrom
feat/agent-sessions-sessionless-traces
Aug 27, 2026
Merged

feat(agent-sessions): surface sessionless GenAI traces as single-trace sessions#655
JeremyFunk merged 3 commits into
mainfrom
feat/agent-sessions-sessionless-traces

Conversation

@JeremyFunk

@JeremyFunk JeremyFunk commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

GenAI traces whose vendor never emits a session key (haystack, litellm, llamaindex, semantic_kernel, effect_ai, and the unknown:* buckets) were invisible in Agent Sessions — ingest stamps maple_ai.vendor.id on them but never maple_ai.session.id. This surfaces each such trace as its own single-trace session: the trace is the full context.

  • List query: the detect stage now keys on maple_ai.vendor.id presence instead of requiring a session id; the outer level groups by if(rawSessionId = '', concat('trace:', traceId), rawSessionId), so sessionless traces become synthesized trace:<traceId> sessions. Vendor resolution uses a ranked argMin(…, tuple(rank, Timestamp)) ordering so sessionless traces still pick a deterministic earliest vendor-stamped span.
  • Facets: restructured to a per-trace inner aggregation so sidebar counts stay correct under the widened guard (a per-span count would have double-counted session-bearing traces).
  • Detail path: new aiTraceWindowQuery / aiTraceSpansQuery keyed directly on TraceId; the API spans handler routes on the trace: prefix via traceSessionTraceId() (prefix + strict 32-hex validation in packages/domain). Malformed prefixed ids fall through to the existing empty-session response, and no unvalidated value reaches the query params.
  • Web needs no structural change — the synthesized id flows through the existing route param and window resolution.

Verified: typecheck green across domain / query-engine-integrations / api / web; 313 query-engine-integrations tests (SQL baseline regenerated), 10 handler tests, 286 web agent-session tests; ClickHouse e2e sweep (bun run ch:test, 302 tests) passes against a real server, covering the new query shapes.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@JeremyFunk
JeremyFunk merged commit bd07c93 into main Aug 27, 2026
33 checks passed
@JeremyFunk
JeremyFunk deleted the feat/agent-sessions-sessionless-traces branch August 27, 2026 19:01
@github-actions

Copy link
Copy Markdown

🍁 Maple PR preview

Warning

Preview cleanup could not be confirmed. The Alchemy teardown outcome was skipped.

Final commit 6d42154 · View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant