fix(hermes): preserve provider response IDs#247
Draft
sipercai wants to merge 3 commits into
Draft
Conversation
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.
Description
This PR makes the Hermes instrumentation prefer the model provider's operation/request identifier for
gen_ai.response.idinstead of the synthetic response identifier produced by Hermes.It adds a shared
util-genaihelper for provider-first response-ID extraction with framework fallback, then uses that helper in Hermes as the first consumer. Hermes observes request-local OpenAI-compatiblechat.completions.createresponses and streaming chunks, isolates retry attempts across worker threads, propagates the selected identifier to LLM and aggregate AGENT spans, and falls back to the Hermes response identifier when the provider does not expose one.For providers such as DashScope,
request_idintentionally has higher priority than the OpenAI-compatible completionid. A later streaming usage trailer carryingrequest_idcan therefore replace an earlier chunkid. Transport-only metadata such as_request_idand HTTP headers is not read implicitly.The Hermes package is also aligned with the OpenTelemetry release set used by LoongSuite 0.7.0: compatible-release floors of API/SDK 1.39.1 and instrumentation/semantic-conventions 0.60b1, with the exact set pinned in tests.
Fixes # (N/A)
Type of change
How Has This Been Tested?
tox -e precommitpyright util/opentelemetry-util-genai/src/opentelemetry/util/genai/response_id.pypytest -q util/opentelemetry-util-genai/tests/test_response_id.py instrumentation-loongsuite/loongsuite-instrumentation-hermes-agent/tests/test_telemetry_spec.pyDoes This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
Validation Evidence
Spec and Scope
request_id,id, orresponse_id; fall back to the Hermes response ID only when no provider value is available.Local Checks
response_id.pyreports 0 errors, 0 warnings, and 0 information messages.Real E2E Matrix
stream-*fallback.Telemetry and Weaver
CI
typecheck, which reported the two Pyright Unknown-type errors fixed by this update.