Catalog PyPI
PACKAGE EXPLORERView in registry

agentscope-otel

PyPI

Python SDK for AgentScope — AI Agent Observability with OpenTelemetry

agentagentscopeaigen-aillmobservabilityopentelemetryotlpsdktracing
Versions collected1
Direct dependencies6From release 0.2.1
Last observed20 Oct, 23:17 UTC

README

Version 0.2.1 documentation

agentscope-otel

Python SDK for AgentScope -- AI Agent Observability.

Installation

pip install agentscope-otel

Quick Start

from agentscope_otel import AgentScope

# Initialize once at startup (3 lines!)
scope = AgentScope.init(
    endpoint="http://localhost:3001",
    project_id="my-project",
)

# Use decorators for automatic span management
@scope.wrap_agent("my-agent", agent_name="researcher", agent_task="Answer questions")
async def run_agent(question: str):
    # Nested tool call -- auto-linked via context propagation
    with scope.trace_tool("web-search") as span:
        results = await search(question)

    # LLM call with auto token tracking
    @scope.wrap_llm_call("generate", model="claude-sonnet-4-5")
    async def call_llm(prompt):
        return await llm.complete(prompt)  # should have input_tokens, output_tokens attrs

    return await call_llm(f"Summarize: {results}")

# Run and clean up
import asyncio
asyncio.run(run_agent("What is AgentScope?"))
scope.flush()

API

Initialization

scope = AgentScope.init(
    endpoint="http://localhost:3001",
    project_id="my-project",
    tenant_id="default",         # optional
    api_key="sk-...",            # optional
    service_name="my-service",   # optional
    debug=True,                  # optional
)

Decorators

@scope.wrap_agent("name", agent_name="...", agent_task="...")
@scope.wrap_tool("name", agent_name="...")
@scope.wrap_step("name")
@scope.wrap_llm_call("name", model="claude-sonnet-4-5")

Context Managers

with scope.trace_agent("name") as span:
    ...
with scope.trace_tool("name") as span:
    ...
with scope.trace_step("name") as span:
    ...

Manual Span Control

span = scope.create_agent_span("name", agent_name="...")
# ... work ...
span.end()

llm_span = scope.create_llm_span("name", model="claude-sonnet-4-5")
# ... call LLM ...
scope.end_llm_span(llm_span, LLMResult(input_tokens=100, output_tokens=50))

Cost Calculation

from agentscope_otel import calculate_cost, MODEL_PRICING

cost = calculate_cost("claude-sonnet-4-5", input_tokens=1000, output_tokens=500)

Supported Models

ModelInput (cents/1M tokens)Output (cents/1M tokens)
gpt-4o2501000
gpt-4o-mini1560
claude-sonnet-4-53001500
claude-haiku-4-580400
claude-opus-4-615007500
gemini-2.0-flash1040

Span Types

  • session -- Top-level session grouping
  • agent_run -- Agent execution
  • step -- Generic step within an agent
  • tool_call -- Tool invocation
  • llm_call -- LLM API call
  • sub_agent -- Nested agent invocation

Example

A runnable quickstart is included in examples/quickstart.py:

python examples/quickstart.py

Requirements

  • Python 3.10+
  • OpenTelemetry Python SDK

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.2.17 May 20266

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
moklabs/agentscope

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:17 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:c1bd89e17aec76fe3c5dd2c961a3c42e9dd04c44f3c69c107b199b44fc41ceed