Conversation
LLM spans carry the agent under the OpenInference key only, so a consumer reading the OpenTelemetry GenAI conventions sees the provider, model and token usage but no agent attribution — it cannot tell a build request from a plan request, or from a named subagent. Mirror the value onto gen_ai.agent.name, taken from the semantic-conventions package already in the dependency tree. Nothing is renamed or removed, so OpenInference consumers are unaffected. agent.type has no GenAI equivalent and is left as-is. Scoped to LLM spans, matching the issue. Tool, subtask and session spans also set the OpenInference key and could follow if that is wanted. The tests assert the literal attribute string rather than the constant the source imports: that string is the wire format consumers match on, so a constant renamed upstream should fail the suite rather than silently change what goes over the wire. Closes DEVtheOPS#126 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #126.
Problem
LLM spans carry the agent under the OpenInference key only:
A consumer reading the OpenTelemetry GenAI conventions therefore sees the
provider, model and token usage but no agent attribution — it cannot tell a
buildrequest from aplanrequest, or from a named subagent.Change
Mirror the value onto
gen_ai.agent.name, usingATTR_GEN_AI_AGENT_NAMEfrom@opentelemetry/semantic-conventions(already a dependency). Nothing isrenamed or removed, so OpenInference consumers are unaffected.
agent.typehas no GenAI equivalent and is left as-is.Scope
LLM spans only —
startMessageSpanand the completion path inhandleMessageUpdated— matching the issue. Tool, subtask and session spansalso set the OpenInference key and could follow if that is wanted; happy to
extend this PR or send a second one.
A distinction worth preserving
Some backends use a field called
agentfor the coding assistant itself(
claude-code,gemini-cli, …) rather than an agent within it. This value isnot that — it is opencode's internal agent — so it deliberately is not mapped
onto a bare
agentkey.That identity already travels correctly on the resource as
service.name = opencode. Anyone whose backend keys on a bareagentattribute can set it today with no code change:
Tests
Two added to
tests/handlers/spans.test.ts; both fail against unpatchedsource. They assert the literal attribute string rather than the imported
constant, since that string is the wire format consumers match on — a rename
upstream should fail the suite rather than silently change the payload.
bun run lint,bun run check:jsdoc-coverage,bun run typecheckall pass.Relationship to #125
Independent — this branches from
mainand can merge in either order. Bothtouch adjacent lines in
message.ts, so whichever lands second may need atrivial rebase.