You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: 2.0 version how to get the requestId by the inference service provider #2231
AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the solution you'd like
In AgentScope 1.0, the request ID returned by the inference service provider could be obtained via gen_ai.response.id. However, this is no longer accessible in version 2.0. Would you consider adding this capability back?
Category: enhancement | Status: Partly available today, real gap confirmed (reviewed against main@3c1c29c01, read-only static inspection; no runtime reproduction)
What already works. The provider-side response/request id is captured for most providers and reachable without a telemetry span:
The final assistant Msg carries it too: ReasoningContext.java:87 stores chunk.getId(), :202 applies it in buildFinalMessage().
The GenAI attribute still exists on the legacy studio tracer path: GenAiIncubatingAttributes.GEN_AI_RESPONSE_ID (:90), populated in AttributesExtractors.java:223 and emitted by TelemetryTracer.java:150.
Confirmed gaps — these are what make 2.0 feel like a regression versus 1.0:
The 2.0-recommended OTel path never emits gen_ai.response.id.OtelTracingMiddleware.setModelResponseAttributes(...) (agentscope-core/src/main/java/io/agentscope/core/tracing/OtelTracingMiddleware.java:354-368) sets only usage/token attributes. TracerRegistry is @Deprecated(forRemoval = true, since = "2.0.0") and its javadoc directs new applications to OtelTracingMiddleware — so anyone migrating off the studio tracer silently loses the attribute they had in 1.0.
Anthropic streaming drops the provider id on the final message.messageId is assigned only inside the message_start branch (AnthropicResponseParser.java:157,163); other stream events return .id(null) (:264), and ChatResponse.Builder.build() then substitutes a random UUID (ChatResponse.java:198-203).
Ollama has no provider id at all, so its value is always that synthetic UUID — worth stating in the docs so users do not key idempotency/correlation on it.
No transport reads a request-id response header (x-request-id appears only as an outbound test header); providers that surface the id solely in a header are unreachable.
ModelCallEndEvent.getReplyId() is not the provider id. It is a framework correlation UUID (ReActAgent.java:2651 → new ModelCallEndEvent(replyId, ...) at :2696), and ModelCallInput carries inputs only, so a MiddlewareBase.onModelCall hook has no access to the provider id today.
Feasibility / scope: low-risk and additive. Minimum shape: (a) set GEN_AI_RESPONSE_ID from the aggregated response in OtelTracingMiddleware, (b) keep messageId across Anthropic streaming events so it lands on the final ChatResponse/Msg. Existing per-provider parser tests already assert id propagation (AnthropicResponseParserTest, GeminiResponseParserTest:70, DashScopeResponseParserTest:78, OpenAIClientTest:129); no test asserts the telemetry attribute, so that assertion would need to be added.
We deliberately are not opening a PR yet: (a) this is a feature request rather than a defect, and (b) a maintainer signal is needed on whether the provider id should be a span attribute on the middleware path, a field on ModelCallEndEvent, or both. Reply /approve and we will generate a spec and a PR scoped to gaps 1 and 2.
Status: 72 h feedback window expired — no automated PR will be generated, the proposal window here is closed
The evaluation above (5823839932, posted 2026-09-24T23:16:34Z) reached its 72-hour feedback limit at 2026-09-27T23:16:34Z. Nobody has replied in this thread since, no line in it starts with an approve, revise or reject command, and the evaluation comment drew no reactions, so per our workflow we skip PR generation and this proposal window is closed. No action is needed from anyone.
Standing the window down is a timing call about the bot's own wait, not a verdict on the report or on the request. The issue stays open, and the two gaps the evaluation recorded for the minimum scope still stand as written there: the recommended OpenTelemetry path never emits gen_ai.response.id, and the provider response id is dropped on the Anthropic streaming path before it can reach the final message.
If a first-party patch is wanted later, a reply here carrying a direction is enough to get a spec and a PR generated against current main — specifically, whether the provider id should live as a span attribute on the middleware path, on the model-call end event, or both. The bot simply stops waiting on this thread.
I'd like to contribute a focused fix for the Anthropic streaming response ID loss identified in this issue.
I reproduced it on main@9e43ed836d68f5d054bc0b4af3704d81cd49cecb: message_start contains the provider's message ID, but later content and usage chunks get generated UUIDs, so the final assistant Msg loses the provider ID.
The local patch retains the ID in the existing per-subscription stream state. It preserves the missing/blank-ID compatibility added in #3394, using one generated fallback ID per subscription. Six regression cases cover provider IDs, missing/empty/blank IDs, repeated subscriptions, overlapping subscriptions, and the final accumulated message. All six fail on the original parser and pass with the fix. The Core and Anthropic test suites also pass (2,744 tests reported, 10 existing skips, no failures or errors).
This addresses only the Anthropic parser part of #2231. It does not restore gen_ai.response.id in OtelTracingMiddleware, add a field to ModelCallEndEvent, or capture HTTP request-id headers. I also noticed that #2233 and #2418 touch the parser for thinking/signature support; this patch does not change that behavior, although #2233 overlaps in the stream state class.
Would this narrow fix be welcome as a separate PR? I'm happy to coordinate with those changes.
Activity
huazaizhang commentedon Sep 14, 2026
这个问题修复了没有呢?
oss-maintainer commentedon Sep 24, 2026
Issue Evaluation
Category:
enhancement| Status: Partly available today, real gap confirmed (reviewed againstmain@3c1c29c01, read-only static inspection; no runtime reproduction)What already works. The provider-side response/request id is captured for most providers and reachable without a telemetry span:
ChatResponse.getId()—agentscope-core/src/main/java/io/agentscope/core/model/ChatResponse.java:64-66OpenAIResponseParser.java:363(non-streaming) and:624(stream chunk), fromOpenAIResponse.id(OpenAIResponse.java:71-73)DashScopeResponseParser.java:132maps the JSONrequest_idfieldAnthropicResponseParser.java:108GeminiResponseParser.java:119(response.responseId())Msgcarries it too:ReasoningContext.java:87storeschunk.getId(),:202applies it inbuildFinalMessage().GenAiIncubatingAttributes.GEN_AI_RESPONSE_ID(:90), populated inAttributesExtractors.java:223and emitted byTelemetryTracer.java:150.Confirmed gaps — these are what make 2.0 feel like a regression versus 1.0:
gen_ai.response.id.OtelTracingMiddleware.setModelResponseAttributes(...)(agentscope-core/src/main/java/io/agentscope/core/tracing/OtelTracingMiddleware.java:354-368) sets only usage/token attributes.TracerRegistryis@Deprecated(forRemoval = true, since = "2.0.0")and its javadoc directs new applications toOtelTracingMiddleware— so anyone migrating off the studio tracer silently loses the attribute they had in 1.0.messageIdis assigned only inside themessage_startbranch (AnthropicResponseParser.java:157,163); other stream events return.id(null)(:264), andChatResponse.Builder.build()then substitutes a random UUID (ChatResponse.java:198-203).x-request-idappears only as an outbound test header); providers that surface the id solely in a header are unreachable.ModelCallEndEvent.getReplyId()is not the provider id. It is a framework correlation UUID (ReActAgent.java:2651→new ModelCallEndEvent(replyId, ...)at:2696), andModelCallInputcarries inputs only, so aMiddlewareBase.onModelCallhook has no access to the provider id today.Feasibility / scope: low-risk and additive. Minimum shape: (a) set
GEN_AI_RESPONSE_IDfrom the aggregated response inOtelTracingMiddleware, (b) keepmessageIdacross Anthropic streaming events so it lands on the finalChatResponse/Msg. Existing per-provider parser tests already assert id propagation (AnthropicResponseParserTest,GeminiResponseParserTest:70,DashScopeResponseParserTest:78,OpenAIClientTest:129); no test asserts the telemetry attribute, so that assertion would need to be added.We deliberately are not opening a PR yet: (a) this is a feature request rather than a defect, and (b) a maintainer signal is needed on whether the provider id should be a span attribute on the middleware path, a field on
ModelCallEndEvent, or both. Reply/approveand we will generate a spec and a PR scoped to gaps 1 and 2.Automated evaluation by github-manager-bot
oss-maintainer commentedon Sep 27, 2026
Status: 72 h feedback window expired — no automated PR will be generated, the proposal window here is closed
The evaluation above (
5823839932, posted 2026-09-24T23:16:34Z) reached its 72-hour feedback limit at 2026-09-27T23:16:34Z. Nobody has replied in this thread since, no line in it starts with an approve, revise or reject command, and the evaluation comment drew no reactions, so per our workflow we skip PR generation and this proposal window is closed. No action is needed from anyone.Standing the window down is a timing call about the bot's own wait, not a verdict on the report or on the request. The issue stays open, and the two gaps the evaluation recorded for the minimum scope still stand as written there: the recommended OpenTelemetry path never emits
gen_ai.response.id, and the provider response id is dropped on the Anthropic streaming path before it can reach the final message.If a first-party patch is wanted later, a reply here carrying a direction is enough to get a spec and a PR generated against current
main— specifically, whether the provider id should live as a span attribute on the middleware path, on the model-call end event, or both. The bot simply stops waiting on this thread.Automated by github-manager-bot
CCCLL commentedon Oct 5, 2026
I'd like to contribute a focused fix for the Anthropic streaming response ID loss identified in this issue.
I reproduced it on
main@9e43ed836d68f5d054bc0b4af3704d81cd49cecb:message_startcontains the provider's message ID, but later content and usage chunks get generated UUIDs, so the final assistantMsgloses the provider ID.The local patch retains the ID in the existing per-subscription stream state. It preserves the missing/blank-ID compatibility added in #3394, using one generated fallback ID per subscription. Six regression cases cover provider IDs, missing/empty/blank IDs, repeated subscriptions, overlapping subscriptions, and the final accumulated message. All six fail on the original parser and pass with the fix. The Core and Anthropic test suites also pass (2,744 tests reported, 10 existing skips, no failures or errors).
This addresses only the Anthropic parser part of #2231. It does not restore
gen_ai.response.idinOtelTracingMiddleware, add a field toModelCallEndEvent, or capture HTTP request-id headers. I also noticed that #2233 and #2418 touch the parser for thinking/signature support; this patch does not change that behavior, although #2233 overlaps in the stream state class.Would this narrow fix be welcome as a separate PR? I'm happy to coordinate with those changes.