Skip to main content

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 /executions with execution_id, status="started", sdk_language="python", sdk_version="0.0.1".
  • On normal return: PATCH /executions/{id} with status="completed", ended_at, duration_ms.
  • On exception: PATCH /executions/{id} with status="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:

  1. Attaches a Mesedi MesediCallbackHandler to each agent's LLM — same LLM/tool telemetry as the LangChain integration above, because CrewAI uses LangChain under the hood.
  2. Sets crew.step_callback to emit crewai.agent_action / crewai.agent_finish checkpoint events per agent step.
  3. Sets crew.task_callback to emit crewai.task_completed checkpoint 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mesedi-0.1.0.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mesedi-0.1.0-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

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

Hashes for mesedi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6abd4cf899cea3f9dd4925900b92c20cefbc5f7c3025854c8cb8782be9e0471c
MD5 e536fc5f93dd0d2c1691c61ba47e5be8
BLAKE2b-256 a712a709293b8e46c5f2713d83a6bd2a8910f5a25802beb55c1e49ea37dca1fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mesedi-0.1.0.tar.gz:

Publisher: release-sdk-python.yml on mesedi-ai/mesedi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mesedi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78eb985a551883152a5569cb57038ca8bd1983f81c4ecba71b405dc7cdc37fe3
MD5 b9b36b47e8c7e581b133106e0c54ff09
BLAKE2b-256 d3d23d4edabe958ada3bad23069c97ef8d27e32dfb4a3e07d02c1e06c806b769

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page