LoongSuite AgentScope Instrumentation
LoongSuite instrumentation for AgentScope framework.
Features
- Traces: Distributed tracing for agents, LLMs, tools, and formatters
- Metrics: Performance metrics following OpenTelemetry GenAI semantic conventions
gen_ai.client.operation.duration: Operation duration in secondsgen_ai.client.token.usage: Token usage for input and output
- Events: Detailed event logging for messages and choices
Installation
# Step 1: install LoongSuite distro
pip install loongsuite-distro
# Step 2 (Option C): install this instrumentation from PyPI
pip install loongsuite-instrumentation-agentscope
# Optional app dependency
pip install agentscope
Usage
Auto-instrumentation
loongsuite-instrument \
--traces_exporter console \
--metrics_exporter console \
python your_agentscope_app.py
Manual instrumentation
from opentelemetry.instrumentation.agentscope import AgentScopeInstrumentor
from agentscope.models import DashScopeChatModel
import agentscope
AgentScopeInstrumentor().instrument()
agentscope.init(project="my_project")
model = DashScopeChatModel(model_name="qwen-max")
result = await model(messages)
AgentScopeInstrumentor().uninstrument()
Configuration
Export to OTLP Backend
export OTEL_SERVICE_NAME=my-agentscope-app
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=<trace_endpoint>
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=<metrics_endpoint>
loongsuite-instrument python your_app.py
Content Capture
Control message content capture using environment variables:
# Enable experimental GenAI semantic conventions
export OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental
# Capture content in spans only
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY
# Capture content in events only
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=EVENT_ONLY
# Capture in both spans and events
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_AND_EVENT
# Disable content capture (default)
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=NO_CONTENT
Supported Components
- Models: ChatModelBase and all subclasses (nested
__call__/ proxy chains emit a single LLM span per logical invocation) - Agents: AgentBase and all subclasses (same for stacked
AgentBase.__call__) - ReAct Steps: Per-iteration
react stepspans for ReActAgent (via instance hooks); nested overrides that callsuper()._reasoning/super()._actingstill produce one step per logical iteration - Tools: Toolkit.call_tool_function
- Formatters: TruncatedFormatterBase.format
Skill metadata on tool spans
When a tool execution reads the top-level SKILL.md of a skill already
registered in toolkit.skills, AgentScope enriches that execute_tool span
with:
gen_ai.skill.namegen_ai.skill.idgen_ai.skill.descriptiongen_ai.skill.version
AgentScope v2 exposes skill loading through its built-in Skill viewer tool.
The v2 middleware records the requested skill argument as
gen_ai.skill.name and gen_ai.skill.id; when QwenPaw or AgentScope exposes
the registered skill directory, it also resolves the available description,
workspace-scoped id, and version metadata.
The matching is intentionally conservative:
- only registered skills can match
- only the top-level
SKILL.mdcounts as a skill load - reads under other paths such as
scripts/orreferences/do not emitgen_ai.skill.*
For CoPaw-style workspace layouts, gen_ai.skill.version is resolved from
SKILL.md frontmatter first and falls back to workspace skill.json
metadata.version_text when needed.
Concurrency (agents)
ReAct step tracing stores temporary state on the agent instance for the
duration of each AgentBase.__call__. AgentScope itself models a single
in-flight reply per instance (see AgentBase._reply_task / _reply_id in
agentscope): concurrent overlapping await agent(...) on the same
instance is unsupported and can corrupt traces, hook state, and interrupt
behavior. Use one instance per concurrent conversation, or serialize calls
with a lock or queue.
Visualization
Export telemetry data to:
- Alibaba Cloud Managed Service for OpenTelemetry
- AgentScope Studio
- Any OpenTelemetry-compatible backend (Jaeger, Zipkin, etc.)
Examples
See the main README for complete usage examples.
License
Apache License 2.0
Metadata
Release files for loongsuite-instrumentation-agentscope 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loongsuite_instrumentation_agentscope-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for loongsuite_instrumentation_agentscope-0.9.0-py3-none-any.whl |
Release files / loongsuite_instrumentation_agentscope-0.9.0-py3-none-any.whl
| Download URL | loongsuite_instrumentation_agentscope-0.9.0-py3-none-any.whl |
|---|---|
| Size | 40.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a30c9bfb275347303c2e4be1633687e233d2c459c0a4187dfc0dd4cdf06852b
|
|
BLAKE2b-256 checksum How to use checksums |
54c9abb3f51bc857419d643950f822c2107531edd6a90bbd99b2c735a6803fac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for loongsuite-instrumentation-agentscope 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.