-
Notifications
You must be signed in to change notification settings - Fork 21
[WIP] Refactor agentscope instrument using genai util to replace #82
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: main
Are you sure you want to change the base?
Conversation
commit 6b8e48ebd909636ce4c2d8631b2b382fb5bb8e32
Author: 流屿 <caishipeng.csp@alibaba-inc.com>
Date: Thu Dec 4 20:44:50 2025 +0800
fix: span exporter error
Change-Id: I0e7a55eece19a166236d931bf69e590ea3a76ed1
Co-developed-by: Cursor <noreply@cursor.com>
commit c1f6e3cc23b1dab15d5e6582211ac679588ef871
Author: 流屿 <caishipeng.csp@alibaba-inc.com>
Date: Thu Dec 4 15:51:27 2025 +0800
chore: use new genai util
Change-Id: I681e478ffc86cd774aac5476fddf6ec4f22c68b6
Co-developed-by: Cursor <noreply@cursor.com>
commit cd2448c018efe4a2f5823e20d57862503b448692
Author: 流屿 <caishipeng.csp@alibaba-inc.com>
Date: Thu Dec 4 15:40:38 2025 +0800
refactor: update genai util
Change-Id: I338a57c2a2311551bf293132b6dc54224823c3a1
Co-developed-by: Cursor <noreply@cursor.com>
commit 3141f49745ab756a2bbc89781cb75dd223186ce5
Author: 流屿 <caishipeng.csp@alibaba-inc.com>
Date: Tue Dec 2 23:21:14 2025 +0800
refactor: agentscope use util genai
Change-Id: Ia6dd446c2ff04a9bc62f705b8001d2a978ae983d
Co-developed-by: Cursor <noreply@cursor.com>
commit c6217390ff5a5f704a2ab87c660c9159de41638e
Author: 流屿 <caishipeng.csp@alibaba-inc.com>
Date: Mon Nov 24 14:11:14 2025 +0800
Refactor agentscope instrumentation to standard structure and drop v0 support
Change-Id: Ie267bd9304e8291895d2b4b80914698173598437
Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I16dfafe9ae766d2a36bbee1b773598e143a2af21
Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ib647add02a3828287eba027514ffc3961f672446 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I5f7cf397133843f23cbf98e1af4eed24dc616dab Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I82757e8cf43cc9210d9050be5925370593daf97a Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I41b0f92aad53265e1fa1f65e0da55d8269a6ce9e Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Idb02a70c0aa35eddf323518392544af46c23a1d2 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I5fe34b20168badff7efccb0a6345c566c35f4f34 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I811f5942da5b4c74b7c963a854d187351eb547e4 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Id689c30a61620e97ec29ce9a6d4ae0ca75eb3a2a Co-developed-by: Cursor <noreply@cursor.com>
Cirilla-zmh
left a comment
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.
Great job! Some changes are needed.
| - Message formatting tracing | ||
|
|
||
| ### Note | ||
| - Only supports AgentScope 1.0.0 and above |
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.
This should be highlighted as a breaking change.
| _apply_llm_finish_attributes(span, invocation) | ||
|
|
||
| # LoongSuite Extension | ||
| span.set_status(Status(StatusCode.OK)) |
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.
Shouldn't be OK
| return invocation | ||
|
|
||
| _apply_create_agent_finish_attributes(invocation.span, invocation) | ||
| invocation.span.set_status(Status(StatusCode.OK)) |
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.
Shouldn't be OK here.
| try: | ||
| result_content = _get_tool_result(last_chunk) | ||
| if result_content: | ||
| span.set_attribute("gen_ai.tool.call.result", _serialize_to_str(result_content)) |
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.
Why not modify the implementation with genai-util?
| } | ||
|
|
||
| if tool_id: | ||
| span_attributes[GenAIAttributes.GEN_AI_TOOL_CALL_ID] = tool_id |
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.
Why not modify the implementation with genai-util?
| @@ -0,0 +1,42 @@ | |||
| [pytest] | |||
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.
Please add tests into https://github.com/alibaba/loongsuite-python-agent/blob/main/tox-loongsuite.ini rather than here.
Change-Id: Ia9d28b59748a3f367c35529c5d9ac311eec32954 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I3a46ccb35472c2212f475b2ccefc0df51fa51c2a Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ie4f1c804a22639e6621fc2229d6813bd1d5f8026 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I760e6ba769fe398121bc45bbebdd128fec149f48 Co-developed-by: Cursor <noreply@cursor.com>
Description
This PR refactors the AgentScope instrumentation to use
ExtendedTelemetryHandlerfromopentelemetry-util-genaiinstead of the previous custom implementation. This change provides better consistency with other GenAI instrumentations, improved span lifecycle management.opentelemetry-util-genai: support for metricsFixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Unit Tests:
test_instrumentor.py: Tests for covering instrumentor initialization, instrumentation, and uninstrumentationtest_model.py: Tests for chat model and embedding model instrumentationtest_agent.py: Tests for agent instrumentation with toolstest_span_content.py: Tests for span content captureIntegration Tests: Verified with real AgentScope examples:
structured_output/main.py: Tests structured output with tool callsstream_printing_messages/multi_agent.py: Tests multi-agent conversationsrag/agent_usage.py: Tests RAG functionality with embeddingsTest Configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.