-
Notifications
You must be signed in to change notification settings - Fork 407
feat(llmobs): support manual agent versioning #9808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ const { | |
| INPUT_MESSAGES, | ||
| OUTPUT_MESSAGES, | ||
| TAGS, | ||
| AGENT_VERSION, | ||
| NAME, | ||
| PARENT_AGENT_NAME, | ||
| PARENT_AGENT_SPAN_ID, | ||
|
|
@@ -119,6 +120,7 @@ class LLMObsTagger { | |
| kind, | ||
| name, | ||
| integration, | ||
| version, | ||
| _decorator, | ||
| } = {}) { | ||
| if (!this.#config.llmobs.DD_LLMOBS_ENABLED) return | ||
|
|
@@ -200,6 +202,12 @@ class LLMObsTagger { | |
| const annotationContextPrompt = annotationContext?.prompt | ||
| if (annotationContextPrompt) this.tagPrompt(span, annotationContextPrompt) | ||
|
|
||
| // Stashed rather than tagged: the kind here can still be changed before finish, and | ||
| // only agent spans carry the tag. The span processor materializes it. | ||
| // Annotation context wins over the span's own option, matching `name` above. | ||
| const agentVersion = annotationContext?.agent?.version ?? version | ||
| if (agentVersion) this.tagAgentVersion(span, agentVersion) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When AGENTS.md reference: AGENTS.md:L222-L225 Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
|
|
||
| const routing = storage.getStore()?.routingContext | ||
| if (routing) { | ||
| this._setTag(span, ROUTING_API_KEY, routing.apiKey) | ||
|
|
@@ -361,6 +369,20 @@ class LLMObsTagger { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Stashes a user-supplied agent version on the span. The span processor promotes it to an | ||
| * `agent_version` span tag at finish, but only if the span's final kind is `agent`. | ||
| * @param {import('../opentracing/span')} span | ||
| * @param {string} version | ||
| */ | ||
| tagAgentVersion (span, version) { | ||
| if (typeof version !== 'string' || !version) { | ||
| this.#handleFailure('Agent version must be a non-empty string.', 'invalid_agent_version') | ||
| return | ||
| } | ||
| this._setTag(span, AGENT_VERSION, version) | ||
| } | ||
|
|
||
| /** | ||
| * Validates and tags cost tag keys on an LLMObs span. Cost tag references are validated against | ||
| * the span's already-applied tags, which are read from the registry. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
llmobs.annotate()is called on a non-agent span withagent.version, this call validates the version even though the span processor later drops_ml_obs.agent_versionfor every non-agent kind. A JavaScript caller such asllmobs.trace({ kind: 'workflow' }, () => llmobs.annotate({ agent: { version: 3 } }))therefore throws in the application path for a value that cannot be emitted; the already-commented trace/wrap path has the same root, and this annotate surface is a separate public entry point that needs the same kind gate or drop-before-validation behavior.AGENTS.md reference: AGENTS.md:L222-L225
Useful? React with 👍 / 👎.