Mesedi SDK — guardians for autonomous AI agents. Detect failures, halt runaways, escalate first occurrence.
Project description
Mesedi Python SDK
Status: Phase 2 alpha (v0.0.1). Local-only development; not yet on PyPI.
The Mesedi SDK observes autonomous AI agent runs and ships them to the Mesedi backend for detection and analysis. Today's surface is intentionally tiny:
mesedi.configure(api_key=...)— set up the module-level client@mesedi.wrap— decorate any function as an "agent execution"; the SDK records start, completion (or crash), wall-clock duration, and a stable crash signature suitable for grouping identical exceptions.
The @tool decorator, Anthropic SDK monkey-patch, async event buffer, and
PyPI release land in later sub-slices.
Quickstart (local development)
Prerequisites: Mesedi backend running on localhost:8080 with the bootstrap
dev project. See ../backend/README.md if not yet running.
cd ~/mesedi/sdk-python
python3 -m pip install -e .
cd sandbox
python3 real_agent.py
Or use it programmatically:
import mesedi
mesedi.configure(
api_key="mesedi_sk_dev_local_only",
base_url="http://localhost:8080",
)
@mesedi.wrap
def run_my_agent(query: str) -> str:
# ... your agent logic here ...
return "answer"
run_my_agent("hello")
What lands in the backend
For each @wrap-decorated call:
- On entry:
POST /executionswithexecution_id,status="started",sdk_language="python",sdk_version="0.0.1". - On normal return:
PATCH /executions/{id}withstatus="completed",ended_at,duration_ms. - On exception:
PATCH /executions/{id}withstatus="crashed",crash_signature(SHA-256-derived stable hash of exception type + top of traceback), then the original exception is re-raised.
Network failures during observation NEVER block the wrapped function. The SDK is fail-open: a Mesedi outage degrades to invisibility, not to broken production code.
Framework integrations
If your agent is built on LangChain or CrewAI, you don't have to wrap every
function with @mesedi.tool by hand. Adapter modules under
mesedi.integrations.* translate each framework's native callback or hook
surface into Mesedi telemetry. They're optional: importing mesedi
itself never requires any framework to be installed.
The pattern is the same across frameworks: your function gets @mesedi.wrap
for the execution boundary, and a one-line adapter does the in-execution
event emission.
LangChain
pip install mesedi[langchain]
import mesedi
from mesedi.integrations.langchain import MesediCallbackHandler
@mesedi.wrap
def run_agent(question: str) -> str:
chain = build_chain()
result = chain.invoke(
{"input": question},
config={"callbacks": [MesediCallbackHandler()]},
)
return result["output"]
The callback handler subscribes to LangChain's standard on_llm_start /
on_llm_end / on_tool_start / on_tool_end (etc.) hooks and emits
llm_call and tool_call events with the same wire format as a
hand-written mesedi.emit_llm_call() + @mesedi.tool pair. Detectors —
drift, identical / similar-call loops, tool-failures, cost-velocity,
prompt-injection — see no difference.
CrewAI
pip install mesedi[crewai]
import mesedi
from mesedi.integrations.crewai import instrument_crew
@mesedi.wrap
def run_my_crew(question: str) -> str:
crew = build_crew()
instrument_crew(crew)
return str(crew.kickoff(inputs={"question": question}))
instrument_crew is one line that does three things, all idempotent:
- Attaches a Mesedi
MesediCallbackHandlerto each agent's LLM — same LLM/tool telemetry as the LangChain integration above, because CrewAI uses LangChain under the hood. - Sets
crew.step_callbackto emitcrewai.agent_action/crewai.agent_finishcheckpoint events per agent step. - Sets
crew.task_callbackto emitcrewai.task_completedcheckpoint events per finished task.
Result: the dashboard timeline shows LLM/tool detail interleaved with CrewAI's higher-level reasoning rhythm.
Posture
This SDK ships from the same monorepo as the backend during the local-only
development window. PyPI publication via Trusted Publishing (PEP 740) is
deferred to the post-LOI sequence in ../docs/DEVELOPMENT_CHECKLIST.md.
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 mesedi-0.1.0.tar.gz.
File metadata
- Download URL: mesedi-0.1.0.tar.gz
- Upload date:
- Size: 37.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 |
6abd4cf899cea3f9dd4925900b92c20cefbc5f7c3025854c8cb8782be9e0471c
|
|
| MD5 |
e536fc5f93dd0d2c1691c61ba47e5be8
|
|
| BLAKE2b-256 |
a712a709293b8e46c5f2713d83a6bd2a8910f5a25802beb55c1e49ea37dca1fc
|
Provenance
The following attestation bundles were made for mesedi-0.1.0.tar.gz:
Publisher:
release-sdk-python.yml on mesedi-ai/mesedi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mesedi-0.1.0.tar.gz -
Subject digest:
6abd4cf899cea3f9dd4925900b92c20cefbc5f7c3025854c8cb8782be9e0471c - Sigstore transparency entry: 1605906822
- Sigstore integration time:
-
Permalink:
mesedi-ai/mesedi@3d438f859a756b128ab06736daefe2329f661186 -
Branch / Tag:
refs/tags/sdk-python-v0.1.0 - Owner: https://github.com/mesedi-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk-python.yml@3d438f859a756b128ab06736daefe2329f661186 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mesedi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mesedi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.6 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 |
78eb985a551883152a5569cb57038ca8bd1983f81c4ecba71b405dc7cdc37fe3
|
|
| MD5 |
b9b36b47e8c7e581b133106e0c54ff09
|
|
| BLAKE2b-256 |
d3d23d4edabe958ada3bad23069c97ef8d27e32dfb4a3e07d02c1e06c806b769
|
Provenance
The following attestation bundles were made for mesedi-0.1.0-py3-none-any.whl:
Publisher:
release-sdk-python.yml on mesedi-ai/mesedi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mesedi-0.1.0-py3-none-any.whl -
Subject digest:
78eb985a551883152a5569cb57038ca8bd1983f81c4ecba71b405dc7cdc37fe3 - Sigstore transparency entry: 1605906933
- Sigstore integration time:
-
Permalink:
mesedi-ai/mesedi@3d438f859a756b128ab06736daefe2329f661186 -
Branch / Tag:
refs/tags/sdk-python-v0.1.0 - Owner: https://github.com/mesedi-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk-python.yml@3d438f859a756b128ab06736daefe2329f661186 -
Trigger Event:
push
-
Statement type: