Explainability SDK for tracing, graphing, and policy auditing of AI agents
Project description
AISquare Explainability SDK
Lightweight Python SDK for tracing, graphing, and policy auditing of AI agents. Captures execution traces from any Python agent (Agno, LangChain, plain Python) and delivers them to the AISquare Explainability Gateway.
Installation
pip install aisquare[explainability]
For Agno auto-instrumentation:
pip install aisquare[explainability,agno]
Quick start
import aisquare.explainability as sdk
# Reads EXPLAINABILITY_GATEWAY_URL and EXPLAINABILITY_API_KEY from environment
sdk.init_from_env(service_name="my-agent")
# Run your agent — Agno is auto-instrumented, all spans captured automatically
agent.print_response("...")
# IMPORTANT for short-lived scripts: flush ensures traces reach the gateway
# before the process exits. Long-running services don't need this.
sdk.flush()
What the SDK captures
The SDK collects two layers of signal:
Auto-instrumentation (zero-code): The AgnoAdapter installs openinference-instrumentation-agno, which automatically wraps every Agno agent run, LLM call, and tool invocation as an OTel span.
Manual tracers (governance-grade): Seven context-manager tracers you can add to any Python code — framework-agnostic:
| Tracer | Purpose |
|---|---|
AgentRunTracer |
Wraps a full agent run as the root span |
LLMCallTracer |
Records an LLM inference call with I/O and token counts |
ToolCallTracer |
Records a tool invocation with parameters, result, and errors |
RetrievalTracer |
Records a RAG retrieval with documents and scores |
HumanInterventionTracer |
Records a human-in-the-loop review or correction |
RoutingTracer |
Records a routing/delegation decision with selected and rejected paths |
MemoryTracer |
Records memory read/write operations |
Decorators are also available: @trace_tool and @trace_retrieval.
Manual instrumentation (any framework)
import aisquare.explainability as sdk
sdk.init_from_env()
with sdk.AgentRunTracer(agent_name="MyAgent", run_id="abc-123") as run:
run.set_input("User query")
with sdk.LLMCallTracer(model="gpt-4o-mini", provider="openai") as llm:
response = call_openai(...)
llm.set_input_messages([{"role": "user", "content": "..."}])
llm.set_output_messages([{"role": "assistant", "content": response}])
llm.set_token_counts(prompt=100, completion=50)
with sdk.RoutingTracer(decision_type="tool_selection") as rt:
rt.set_selected("web_search", reason="Query requires fresh data")
rt.set_rejected([{"name": "cached_search", "reason": "Cache is stale"}])
run.set_output("Agent final answer")
sdk.flush()
Environment variables
| Variable | Description |
|---|---|
EXPLAINABILITY_API_KEY |
API key for trace ingest |
Diagnostics
The SDK ships a built-in health checker:
explainability-doctor
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 aisquare-1.0.3.tar.gz.
File metadata
- Download URL: aisquare-1.0.3.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
949c22be6ddc4a157a1ff3c384889f6e185ad3a565392c9ab0e44314bafc5a4c
|
|
| MD5 |
473793aed2b057336819c98778b7d87c
|
|
| BLAKE2b-256 |
15f921be71c323d668e424be1d371aa9100bd9476082fb62681c7a79c787f57a
|
File details
Details for the file aisquare-1.0.3-py3-none-any.whl.
File metadata
- Download URL: aisquare-1.0.3-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76c229acf7a2e9f68ed112beb79b5450fed6afc916eb08e0a048dd05f1ae310f
|
|
| MD5 |
a84dac594fdbb2eb979ce437823bf95a
|
|
| BLAKE2b-256 |
b74ab4e5c7406449b340923a044201aeb8b726945d348b666c5e517e764b043e
|