AgentScope Python SDK
Project description
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 gRPCserver interceptorsCelerytask execution boundarykafka-pythonconsumer poll boundary (best-effort)
Default propagation:
- HTTP headers via
requests - Kafka message headers via
kafka-pythonproducer
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=...
- Cross-run linkage params:
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentscope_sdk-0.1.16.tar.gz.
File metadata
- Download URL: agentscope_sdk-0.1.16.tar.gz
- Upload date:
- Size: 25.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6010af20707c83c7f723b194c34eeb5c2e36df0f4d3f0d7f7e03cdfc59d11986
|
|
| MD5 |
6ffd90bc275d67fd20d048a379638ccb
|
|
| BLAKE2b-256 |
e33e8e53e87ee7304fbd72fb91307ba8d877b85a98718730dbe66d0c67eb97f2
|
Provenance
The following attestation bundles were made for agentscope_sdk-0.1.16.tar.gz:
Publisher:
workflow.yml on dinesh-88/agentscope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentscope_sdk-0.1.16.tar.gz -
Subject digest:
6010af20707c83c7f723b194c34eeb5c2e36df0f4d3f0d7f7e03cdfc59d11986 - Sigstore transparency entry: 1306419682
- Sigstore integration time:
-
Permalink:
dinesh-88/agentscope@2f19d546725670416124d0faf0af090309f9e457 -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/dinesh-88
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@2f19d546725670416124d0faf0af090309f9e457 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentscope_sdk-0.1.16-py3-none-any.whl.
File metadata
- Download URL: agentscope_sdk-0.1.16-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
883f1ad21ca42dd3ab9e5f70d75e7b53f114cd6a99fac12ad19f91efc5a5a5df
|
|
| MD5 |
ff6e0f1a05face914e6337454a8956c4
|
|
| BLAKE2b-256 |
aaae7d30a38fe4acf35829a2d934f8961c3ff3cb4d0ca26eca28c5e969fb236e
|
Provenance
The following attestation bundles were made for agentscope_sdk-0.1.16-py3-none-any.whl:
Publisher:
workflow.yml on dinesh-88/agentscope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentscope_sdk-0.1.16-py3-none-any.whl -
Subject digest:
883f1ad21ca42dd3ab9e5f70d75e7b53f114cd6a99fac12ad19f91efc5a5a5df - Sigstore transparency entry: 1306420197
- Sigstore integration time:
-
Permalink:
dinesh-88/agentscope@2f19d546725670416124d0faf0af090309f9e457 -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/dinesh-88
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@2f19d546725670416124d0faf0af090309f9e457 -
Trigger Event:
push
-
Statement type: