Fail-safe agentic-harness observability SDK for promptstore
Project description
promptstore-telemetry (Python SDK)
Fail-safe agentic-harness observability for promptstore. Emits canonical spans (loops, tool calls, sub-agents, model calls, context-lifecycle events) to a promptstore telemetry endpoint.
Safety guarantees
This SDK is designed so that promptstore can never impact your application:
- Non-blocking — spans are enqueued to a bounded in-memory buffer and flushed by a background daemon thread.
- Never raises into your code — every telemetry operation is guarded. Your own exceptions inside a
with span(...)still propagate (and are recorded as an error status). - Bounded memory — under backpressure the buffer drops the oldest spans.
- Circuit breaker — repeated failures open a breaker and the SDK stops trying (and stops buffering) until a cooldown elapses.
- Zero runtime dependencies — standard library only.
Install
pip install -e sdk/python # from the repo, or publish to your index
Usage
import promptstore_telemetry as ps
ps.configure(base_url="https://promptstore.example.com", api_key="pst_...")
# or set PROMPTSTORE_URL and PROMPTSTORE_TELEMETRY_KEY
with ps.trace("research-agent") as run:
for turn in range(max_turns):
with ps.span(ps.SpanKind.LOOP_ITERATION, f"turn-{turn}"):
with ps.span(ps.SpanKind.MODEL_CALL, "plan") as m:
m.set_model(provider="anthropic", response_model="claude-3-5-sonnet-20241022")
m.set_usage(prompt_tokens=1200, completion_tokens=300, cached_tokens=800)
# context lifecycle — powers the Context view (budget chart,
# composition, change cards). Include sources=[...] for full
# per-source attribution; see docs/telemetry-sdk.md
# ("Instrumenting context") and examples/multi_agent.py.
ps.context_event(ps.ContextEventName.COMPACT,
sources=[{"source": "history", "tokens": 30000,
"label": "summary of earlier turns"}],
window_tokens_before=180000, window_tokens_after=90000,
window_limit=200000,
tokens_reclaimed=90000, method="summarize")
@ps.tool("web_search")
def web_search(q): ...
# sub-agents across processes
with ps.subagent("researcher") as sub:
traceparent = ps.get_traceparent() # hand to the child process
Get a write-only telemetry key from promptstore:
POST /api/workspaces/:workspaceId/telemetry-keys.
Configuration
configure(base_url, api_key, *, flush_interval=2.0, max_batch=128, max_buffer=10000, emit_on_start=True, timeout=5.0, circuit_fail_threshold=5, circuit_cooldown=30.0, redactor=None, deny_keys=None, enabled=True)
emit_on_start— also emit a span when it opens (enables the live view). The server upserts start+end into one row.redactor/deny_keys— PII redaction hooks applied to attributes and event payloads before they leave the process.
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 promptstore_telemetry-0.1.0.tar.gz.
File metadata
- Download URL: promptstore_telemetry-0.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5ee6bea6245cc2fff8b3fb60ec17dcdff790d89ad8979c7a0376380cb8b7f48
|
|
| MD5 |
e3ba04d51f18455c4489b0d12a30cd53
|
|
| BLAKE2b-256 |
1ccecd334860f5544d1963ef6eaa7ee8bd41d7bab1a2d8922945cce0eac22987
|
File details
Details for the file promptstore_telemetry-0.1.0-py3-none-any.whl.
File metadata
- Download URL: promptstore_telemetry-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebc0ff54442259476bf7ba5f9af8f91ded8899ae6c78c1852182362c412886bb
|
|
| MD5 |
1571e61ab70597e9607fb5c55248f5c6
|
|
| BLAKE2b-256 |
1cec90ed25c68ac7ecd59609d251eabadf0e87ad99f69b2d322ad4646c994847
|