Python SDK for Pathlight — visual debugging and observability for AI agents
Project description
pathlight — Python SDK
Python SDK for Pathlight — visual debugging, execution traces, and observability for AI agents.
Install
pip install pathlight
Usage
from pathlight import Pathlight
pl = Pathlight(base_url="http://localhost:4100")
with pl.trace("research-agent", input={"query": "What is WebAssembly?"}) as trace:
with trace.span("classify", type="llm", model="gpt-4o") as s:
result = openai.chat.completions.create(...)
s.end(
output=result.choices[0].message.content,
input_tokens=result.usage.prompt_tokens,
output_tokens=result.usage.completion_tokens,
cost=0.003,
)
with trace.span("web-search", type="tool", tool_name="search") as t:
docs = search_tool("WebAssembly")
t.end(tool_result=docs)
trace.end(output=final_answer)
Context-manager exits auto-close the trace/span. Raised exceptions mark the
enclosing trace/span as failed with the exception message as the error.
Async
from pathlight import AsyncPathlight
async with AsyncPathlight(base_url="http://localhost:4100") as pl:
trace = await pl.trace("agent")
async with await trace.span("llm.chat", type="llm") as s:
... # do work
await s.end(input_tokens=50, output_tokens=10)
await trace.end(output=result)
Features
All the dashboard features that the TypeScript SDK surfaces are available here too:
- Auto git-context capture — commit, branch, dirty flag via
gitsubprocess (cached once per process). - Auto source-location capture — stack-walk skips
pathlight/and stdlib frames, storesmetadata._sourceso the dashboard showsfile:linefor every span. - Live breakpoints —
pl.breakpoint(label=..., state=...)blocks until the dashboard resumes, returns the (possibly edited) state. - Fully typed with a
py.typedmarker.
Reference
Pathlight(...)
| kwarg | type | purpose |
|---|---|---|
base_url |
str |
Collector URL (required) |
project_id |
str | None |
Group for multi-project installations |
api_key |
str | None |
Bearer token sent as Authorization: Bearer … |
disable_git_context |
bool |
Skip auto-detection of commit/branch |
git |
GitContext | None |
Explicit override (wins over auto-detect) |
timeout |
float |
httpx client timeout in seconds (default 10) |
Trace.span(name, *, type="custom", ...)
Returns a Span. Types: "llm", "tool", "retrieval", "agent",
"chain", "custom".
Span.end(*, output=None, input_tokens=None, output_tokens=None, cost=None, tool_result=None, ...)
Closes the span. All kwargs optional; use status="failed" + error=...
for explicit failure.
pl.breakpoint(*, label, state=None, timeout_ms=None)
Registers a breakpoint and blocks until the dashboard resumes it. Returns
whatever the dashboard posted back (the edited state); falls back to the
original state on timeout or collector failure.
License
MIT
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 pathlight-0.2.0.tar.gz.
File metadata
- Download URL: pathlight-0.2.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96289c4489bbf13bdcbde87a39c80a1b53c1f6717fde09fcf7272102dd8f2413
|
|
| MD5 |
67d6ad8c3c1ce1dfdcb0a0f25b1d3bad
|
|
| BLAKE2b-256 |
0d8b061acff599d46d849af0a4e427100fb6491025779973567ef50e8e100845
|
File details
Details for the file pathlight-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pathlight-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
511456ec32160d1377dedb51b16605aa506077c51909c64e2b42c3027960d3e5
|
|
| MD5 |
0525ecf888ccf3ab6f5fdfacc7c8c8e8
|
|
| BLAKE2b-256 |
1aff9e0195f8d4dd24b1b510bec48111fd2631a0ff3bbf211927e31262b4a80d
|