Repository navigation
Conversation
Spans started by the FI tracer whose start attributes hold a non-empty session.id also get gen_ai.conversation.id with the same value, unless the span sets that key itself. The export boundary treats gen_ai.conversation.id as a grouping key, like session.id, on spans made by an FI tracer.
…sation id follows session.id at export On spans not made by an FI tracer, a gen_ai.conversation.id equal to the span's raw session.id is exported exactly as that session.id is, so the two keys get the same exposure. Codex item spans and Cursor child spans set gen_ai.conversation.id to the thread id or agent id that their root span uses, so every span in a trace carries one conversation id, also when the app sets session.id.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Spans started by the FI tracer in
@traceai/fi-corethat carrysession.idalso carrygen_ai.conversation.idwith the same value, unless the span sets that attribute itself. Traces can then be grouped by conversation from TypeScript, as they can from Python (which sets both from a session).Why?
Python's
using_sessionsetssession.idandgen_ai.conversation.id; TypeScript set onlysession.id, so conversation grouping did not work for TypeScript apps.The value is taken from the span's final
session.id, after context attributes and the span's own attributes are merged, so the two match on every span. Spans that are not created by the FI tracer (for example application spans exported through an integration) do not get the attribute, so it does not appear wheresession.idis treated differently. The conversation id gets the same export privacy treatment assession.id(grouping-key exemption and withheld marker). On spans that are not created by the FI tracer, agen_ai.conversation.idequal to that span'ssession.idis exported exactly as itssession.idis, so the two values cannot differ in exposure.In the Codex and Cursor integrations, child spans carry the same
gen_ai.conversation.idas their root (the thread id or agent id), so one trace carries one conversation id.How was it tested?
New
src/__tests__/conversationId.test.ts: a session sets both; a span overridingsession.idgets the overriding value; an explicitgen_ai.conversation.idis kept;setAttributesoverrides are followed; no session sets neither; both stay equal after the export privacy filter, including with PII redaction.Codex and Cursor wrapper tests: with an app session, the root and every child carry the same conversation id.
Updated exact-attribute expectations in
startSpanContext.test.ts,fitracerStartSpanContext.test.ts,round6-boundary.test.tsand thetraceai_openaiinline snapshot;traceai_genkitasserts application spans carry nogen_ai.conversation.id.Before/after counts with no new failures: fi-core jest (both otel lines), fi-core node tests, semantic conventions, openai (jest, contracts, gateway), genkit, auto (including its e2e test), codex, cursor, claude-agent, vercel, elevenlabs and google-genai suites. fi-core typecheck: 0 errors.
Unit tests added / updated (
vitest/jest)Integration tests pass (or N/A — no gateway behavior changed)
npm run typecheck/npm run lintall passPublic types, env vars, or SDK behavior changes are documented (fi-core CHANGELOG)
Checklist
docs/VOCABULARY.mdNotes for reviewers
Targets
dev. The added attribute takes one slot of the span attribute count limit when a session is set.