Repository navigation
fix(qwen-agent): scope stream invocation context to execution - #919
Open
123liuziming wants to merge 2 commits into
Open
123liuziming wants to merge 2 commits into
123liuziming wants to merge 2 commits into
Conversation
Assisted-by: ChatGPT GPT-6
Pull request dashboard statusWaiting on the author · refreshed 2026-10-20 02:02 UTC Respond to 2 review items (e.g. link a commit, explain why not, ask a follow-up): Status above doesn't look right?
|
Assisted-by: ChatGPT GPT-6
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes follow the shared stream lifecycle and include targeted regression coverage, with no unresolved findings.
No open issues 🎉
What changed in this PR
Addresses the Qwen-Agent portion of #872 by limiting stream invocation context to execution and cleanup while preserving caller context.
Changes:
- Uses the shared stream wrapper’s execution-scoped context.
- Suppresses inference chunk-timing metrics for local agents.
- Adds lifecycle regression tests and documents stream behavior.
| File | Description |
|---|---|
| util/opentelemetry-util-genai/tests/test_handler_metrics.py | Verifies agent-only duration metrics. |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/_agent_invocation.py | Disables local-agent chunk timing. |
| util/opentelemetry-util-genai/.changelog/0.fixed | Records the metrics fix. |
| instrumentation/opentelemetry-instrumentation-genai-qwen-agent/tests/test_agent.py | Tests context isolation, cleanup, parenting, and metrics. |
| instrumentation/opentelemetry-instrumentation-genai-qwen-agent/src/opentelemetry/instrumentation/genai/qwen_agent/patch.py | Passes and suspends the stream invocation. |
| instrumentation/opentelemetry-instrumentation-genai-qwen-agent/README.rst | Documents stream context and lifecycle. |
| instrumentation/opentelemetry-instrumentation-genai-qwen-agent/.changelog/0.fixed | Records the context fix. |
Review effort: Balanced
eternalcuriouslearner
approved these changes
Oct 19, 2026
eternalcuriouslearner
left a comment
Contributor
There was a problem hiding this comment.
Thanks for this contribution!!
lmolkova
reviewed
Oct 20, 2026
Comment on lines
+235
to
+236
| def _on_stream_chunk(self, chunk_at: float) -> None: | ||
| """Local agent streams scope context without inference chunk timing metrics.""" |
Member
Comment on lines
+55
to
+56
| when stopping early. Agent streams record agent duration without LLM chunk | ||
| timing metrics. |
Member
There was a problem hiding this comment.
nit: the metrics detail is an implementation note, not something users need to act on.
Suggested change
| when stopping early. Agent streams record agent duration without LLM chunk | |
| timing metrics. | |
| when stopping early. |
This branch has not been deployed
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
Addresses the Qwen-Agent portion of #872 by making agent spans current only during stream reads and cleanup, preserving caller context and nested spans across tasks. Local agent invocations no longer emit inference chunk timing metrics.
Type of change
Validation
Checklist