Add gen_ai.user.id for the user interacting with a GenAI session #552
<!-- pull-request-dashboard-status -->
<!-- pull-request-dashboard-status-revision:25 -->
Pull request dashboard status
Waiting on reviewers · refreshed 2026-12-04 04:36 UTC
Review the latest changes.
Also blocked by: Merge conflicts.
<details>
<summary>Status above doesn't look right?</summary>
<br>
/dashboard route:author to route it back.</details>
This shared attribute group feeds both the client and internal invoke_agent spans, but the PR only demonstrates the internal case. The regenerated client report confirms the gap with user.id | (none) at reference/reports/invoke-agent-client-span.md:63. Please add a client-library scenario where the value comes from the client API, or keep user.id off the client span until that capturability can be shown.
This does not establish invoke_workflow coverage. The runner is configured with a standalone Agent at lines 180-198, while this model explicitly says not to report a workflow span for standalone agent invocations and lists ADK Runner.run(...) only with a multi-agent or graph workflow. Use an actual ADK workflow such as SequentialAgent for this emission, or remove the workflow coverage claim until such a scenario exists.
<!-- ccr-overview-v2 -->
Copilot review overview
🟡 Changes recommended
Client coverage is missing, and the workflow coverage uses a standalone agent rather than an ADK workflow.
Review effort: Balanced
Findings: 2 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture>
<details open>
<summary><strong>Open (2)</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds opt-in user.id support to agent and workflow spans for per-user correlation.
Changes:
user.id to agent and workflow span models and generated documentation.| File | Description |
| ---- | ----------- |
| model/gen-ai/spans.yaml | Adds the span attributes. |
| docs/gen-ai/gen-ai-agent-spans.md | Regenerates span tables. |
| reference/scenarios/google-adk/scenario.py | Emits user.id. |
| reference/scenarios/google-adk/README.md | Documents the source value. |
| reference/scenarios/google-adk/data.json | Records emitted coverage. |
| reference/reports/invoke-agent-client-span.md | Reports missing client coverage. |
| reference/reports/invoke-agent-internal-span.md | Reports ADK internal coverage. |
| reference/reports/invoke-workflow-span.md | Reports ADK workflow coverage. |
| changelog.d/+.enhancement.1.md | Adds the release note. |
</details>
---
💡 Configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
Thanks. I initially moved user.id off the shared group, but after re-evaluating the proposal I chose to align it with gen_ai.conversation.id across the applicable GenAI operation spans in 3c092ab1. The client report intentionally remains (none): none of the current client reference APIs expose a real application-user identifier, and I do not want to synthesize one solely to claim coverage. The updated PR description calls out this gap explicitly so the community can review the symmetric model and narrow client usage later if needed.
Addressed in 3d19a11c. The ADK runner now uses a real SequentialAgent(name="test_workflow", sub_agents=[agent]) as its root agent, and the invoke_workflow span wraps that workflow execution. The reference coverage therefore no longer comes from a standalone Agent.
Is it applicable besides ADK? Are there other frameworks that have the notion of user id in the API directly?
ADK is the clearest case. Microsoft Agent Framework also has framework-defined user principals (tenant_id + user_id) in its security context, although that API is currently experimental rather than part of the general agent invocation API. I only added ADK coverage for now. Do you think the Agent Framework case should also map to user.id?
the main concern is that user.id is known to be problematic because it's too broad and could mean anything from end user making request in the browser and to OS user which executes the running process or IAM human identity used to make specific model call - https://github.com/open-telemetry/semantic-conventions/issues/1172.
So we need to define some other attribute that would not collide with the generic one (what if app stamps user.id on all telemetry already via context and it's different than one used on Google ADK?). Or maybe ADK thing is expected to be that opaque id?
So need to understand how user id is used in ADK and other places and from there we can define if it's a framework-specific attribute or a more general one.
<!-- pull-request-dashboard-author-nudge:692b9c222b814cfaa68f0ebd06db8cfe -->
Hi @steverao — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.
/dashboard route:reviewers.<!-- pull-request-dashboard-author-nudge-completed:692b9c222b814cfaa68f0ebd06db8cfe -->
_Outdated as of 2026-10-19 18:51 UTC: this reminder no longer reflects the current dashboard state. Check the dashboard status comment to see whether action is needed._
In ADK, this is an application-provided identifier for the user that owns the session and its state. AgentScope and Agno expose a similar concept for partitioning session/state or user memory, so it does not seem ADK-specific.
It is not intended to represent an OS user or the IAM identity used to call the model. I agree that mapping it to the generic user.id may collide with an identity already recorded by the application.
Would a GenAI-specific gen_ai.user.id, with this narrower meaning, make more sense here?
I'm also unclear on when and how to use the existing OpenTelemetry attributes on gen_ai. spans, specifically when it comes to standardizing how GenAI spans are ingested and displayed in UIs. It feels counterintuitive to add something like gen_ai.user.id when OpenTelemetry already has user.id.
what if app stamps user.id on all telemetry already via context and it's different than one used on Google ADK
I would expect user.id to flow through the app as a constant ID and mean the same thing in every context, which is the end user. I understand the general definition is broad, but the GenAI semantic conventions can narrow it on their own spans, and this PR's wording ("the user on whose behalf the model is invoked") already does that. If the app has already set user.id, the instrumentation shouldn't overwrite it. If a framework needs a user identifier that means something different, I would expect a separate gen_ai. attribute for that case.
Thank you both for tackling this problem!
Hi @lmolkova, based on our previous discussion about the ambiguity of user.id, I looked more closely at how user identifiers are used across GenAI frameworks and model-provider APIs.
I agree that directly mapping a framework-provided user identifier to the generic user.id could collide with an identity already propagated by the application. This is especially relevant given the broader ambiguity discussed in open-telemetry/semantic-conventions#1172.
There does appear to be a recurring GenAI-specific concept that is separate from the conversation itself:
Session.userId links a conversation to a particular user, while the session ID identifies the individual conversation thread.
user_id, which identifies the person/auth subject across sessions, from session_id, which identifies one conversation thread.
user_id separately from session_id, using it to differentiate users and support per-account accounting.
However, similar-looking identifiers do not always have the same meaning:
@MemoryId can distinguish either users or conversations, so it is a memory-partition key rather than an unambiguous user identity.
tenant_id and user_id as an authorization principal. That may represent a different identity domain and should not be mapped automatically.
metadata.user_id and OpenAI’s safety_identifier identify an external application user for provider-specific safety and abuse-detection purposes. OpenAI also allows a session identifier for anonymous users, which demonstrates why the field name alone is not sufficient evidence for mapping.
Based on these distinctions, I think a separate gen_ai.user.id would be safer than reusing the generic user.id.
I propose defining it as:
gen_ai.user.id: The unique identifier of the application-level user on whose behalf the GenAI operation is performed, as explicitly provided to or exposed by the GenAI framework or provider.
The intended boundaries would be:
user_id.
session_id, gen_ai.conversation.id, memory_id, or another value that is only a state-partition key.
user.id; the two values are not assumed to be equal.
user.id.
I would not place this under gen_ai.conversation.*, because the same user may span multiple conversations and is not intrinsically a property of one conversation.
Would this narrower definition of gen_ai.user.id address the collision and ambiguity concerns?
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
The shared attribute introduces a remote client-agent requirement without demonstrated API coverage, leaving a convention-boundary decision that the author explicitly reserves for community review.
No open issues 🎉
<details>
<summary><strong>2 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
please add sensitive information warning as recommended in https://github.com/trask/semantic-conventions/blob/9e2eb2fd3016acf7ae6d7555340fc159c2f9c6bd/docs/how-to-write-conventions/README.md?plain=1#L85
should this be recommended (here and on the other two spans)? It's a user identifier, and conditionally required makes instrumentations emit it by default with no clear way to turn it off.
also I don't think we need to repeat the attribute brief in the requirement level.
- ref: gen_ai.user.id
requirement_level:
recommended: When applicable.
we don't really know if it's an application user - it's whatever is set in the corresponding field in the SDK
brief: The identifier of the user as known to the GenAI agent framework or another component.
Can we be tighten it up, remove mentions of user.id which has no conflict now and provide more examples? I.e. talk about what it is rather than what it's not?
The value SHOULD map to a user concept defined by the library or component,
for example:
- Google ADK [`Session.user_id`](https://adk.dev/sessions/session/)
- Agno [`Agent.run(user_id=...)`](https://docs.agno.com/reference/agents/agent)
- Amazon Bedrock AgentCore [`runtimeUserId`](https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_InvokeAgentRuntime.html)
Instrumentations SHOULD NOT set this attribute if corresponding component does
not have a notion of user.
The compaction request omits it.
why? is this how it intends to work?
I don't think we document low level scenario details in this file.
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues block the addition of gen_ai.user.id to the GenAI conventions.
No open issues 🎉
<sub>Review effort: Balanced</sub>
question: this group also feeds the client invoke_agent span, but no scenario emits it there. Is there an agent SDK that exposes the user on a remote agent call? Bedrock AgentCore InvokeAgentRuntime(runtimeUserId=...) might be one.
nit, can you please add a comment pointing to user_id being top-level property and recognized by anthropic SDK, otherwise it might look like random app-defined constant
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues block the addition of gen_ai.user.id for per-user telemetry correlation.
No open issues 🎉
<sub>Review effort: Balanced</sub>
steverao
Description
Add
gen_ai.user.idto identify the user interacting with a GenAI session, as identified by the instrumented framework or component. It is recommended when applicable on inference, agent invocation (including workflows), and tool execution spans. Inference operation details events share the inference span's attribute group.The field describes the session's interacting user. Browser login state, visitor cookies, and the identity used to authenticate or authorize an operation do not establish that user by themselves. Instrumentation reads the component's defined user field and omits the attribute when the component does not expose this concept. The registry includes a sensitive-information warning.
Related to #83.
Motivation
Correlate GenAI operations for incident triage and per-user quality analysis using the framework or provider's session-user concept. Keep the user identifier distinct from the conversation identifier.
Reference coverage
Session.user_id, runneruser_id, andToolContext.session.user_id, with explicit assertions for runner, internal agent,SequentialAgentworkflow, and tool spans.metadata.user_idon ordinary and compaction requests, plus a separate ordinary request without a user ID.InvokeAgentRuntime(runtimeUserId=...)on clientinvoke_agentspans, including a request without that parameter. The scenario checks the SDK's serialized user header and keepsruntimeSessionIdseparate. It mocks the HTTP response while exercising real SDK validation, serialization, and response parsing. The Runtime API has no standardized model token usage or finish reasons; the conformance configuration documents those exceptions.Validation
make check-policies,make generate-all, andmake test-json-schemas(33 tests).git diff --check.Checklist
changelog.d/for the consumer-visible convention change