Skip to main content

AgentScope Python SDK

Python SDK for AgentScope telemetry, tracing, and instrumentation.

Install

pip install agentscope-sdk

Quick Start

from agentscope import observe_run, observe_span, trace

with observe_run("coding_agent", agent_name="demo"):
    with observe_span("llm_call", provider="openai", model="gpt-4o"):
        trace.log("sending prompt", level="info")

Set AGENTSCOPE_API_BASE=http://localhost:8080 and AGENTSCOPE_API_KEY=... as needed.

Anonymous SDK Telemetry (Optional)

Telemetry is sent only after explicit consent.

On first interactive SDK run, AgentScope prompts:

AgentScope Telemetry

We collect anonymous usage data to:
- improve debugging insights
- understand feature usage

We DO NOT collect:
- prompts
- outputs
- personal data

Enable telemetry? (y/N)

Consent is persisted in ~/.agentscope/config.json:

{
  "telemetry_enabled": true,
  "consent_timestamp": "2026-04-06T10:00:00Z"
}

Override options:

export AGENTSCOPE_TELEMETRY=on   # or off
import agentscope

agentscope.init(telemetry=True)   # or False

CLI consent management:

agentscope telemetry enable
agentscope telemetry disable

When enabled, the SDK sends only anonymous events (sdk_init, run_start, run_end) to POST /v1/telemetry using an anonymized project_id persisted at ~/.agentscope/config.json. Prompt/output content and user payloads are never sent by this channel.

Auto Instrumentation

from agentscope import auto_instrument

auto_instrument(["openai", "anthropic"])

This enables automatic provider tracing, orchestration boundary detection, and context propagation.

Default orchestration detectors:

  • HTTP ASGI (FastAPI/Starlette) request boundary
  • gRPC server interceptors
  • Celery task execution boundary
  • kafka-python consumer poll boundary (best-effort)

Default propagation:

  • HTTP headers via requests
  • Kafka message headers via kafka-python producer

Each boundary creates/continues one root orchestration run so agent runs inside that boundary share one trace_id automatically.

Disable orchestration auto-detection if needed:

auto_instrument(["openai"], orchestration=False)

Choose specific transports:

auto_instrument(["openai"], orchestration=["http", "grpc"])

Disable propagation injection:

auto_instrument(["openai"], propagation=False)

Coding-Agent Helpers

from agentscope import coding_agent_run, read_file, run_command, write_file

with coding_agent_run(agent_name="codebot"):
    content = read_file("README.md")
    write_file("notes.txt", content)
    result = run_command("echo done")

API

  • observe_run(...)
    • Cross-run linkage params: trace_id=..., parent_run_id=..., root_run_id=...
  • observe_span(...)
  • trace.auto(providers=None)
  • trace.log(message, level="info", span_id=None, metadata=None, timestamp=None)
  • trace.update_span(span_id, data)
  • auto_trace(providers=None)
  • auto_instrument(providers=None, orchestration="auto", propagation=True, orchestration_workflow_name="orchestration_auto_trace", orchestration_agent_name="orchestrator")
  • coding_agent_run(agent_name="coding_agent")
  • instrument_coding_agent(fn)
  • read_file(path, encoding="utf-8")
  • write_file(path, content, encoding="utf-8")
  • run_command(command, cwd=None, env=None, check=False, shell=None)

Release files for agentscope-sdk 0.1.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentscope-sdk 0.1.16
File Size Uploaded
agentscope_sdk-0.1.16.tar.gz 25.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentscope-sdk 0.1.16
File Interpreter ABI Platform
agentscope_sdk-0.1.16-py3-none-any.whl Python 3 none any Details

Total release size: 60.5 kB

Release files / agentscope_sdk-0.1.16.tar.gz

Download URL agentscope_sdk-0.1.16.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6010af20707c83c7f723b194c34eeb5c2e36df0f4d3f0d7f7e03cdfc59d11986
BLAKE2b-256 checksum
How to use checksums
e33e8e53e87ee7304fbd72fb91307ba8d877b85a98718730dbe66d0c67eb97f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.

Transparency log

Release files / agentscope_sdk-0.1.16-py3-none-any.whl

Download URL agentscope_sdk-0.1.16-py3-none-any.whl
Size 35.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
883f1ad21ca42dd3ab9e5f70d75e7b53f114cd6a99fac12ad19f91efc5a5a5df
BLAKE2b-256 checksum
How to use checksums
aaae7d30a38fe4acf35829a2d934f8961c3ff3cb4d0ca26eca28c5e969fb236e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.16 This release

2 release files

0.1.15

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page