Skip to main content

Mudipu Python SDK

Instrument, analyze, and optimize your AI agents

Python 3.11+ PyPI version License: MIT

Mudipu is a lightweight Python SDK for tracing, analyzing, and improving LLM-powered applications. Add instrumentation in minutes, detect inefficiencies, and measure context health—all without sending data to external services.

✨ Key Features

  • 🎯 Zero-friction instrumentation - Add tracing with simple decorators
  • 📊 Context health metrics - Detect loops, drift, redundancy, and saturation
  • 💰 Cost tracking - Automatic token usage and cost estimation
  • 🔍 Rich analysis - CLI tools and programmatic APIs
  • 🔒 Privacy-first - Local-first architecture, no data leaves your machine
  • 📤 Multiple export formats - JSON, HTML, and more

🚀 Quick Start

Installation

# Basic installation
pip install mudipu

# With health metrics support
pip install mudipu[health]

# With all features
pip install mudipu[all]

30-Second Example

from mudipu import trace_session, trace_llm
from openai import OpenAI

client = OpenAI()

@trace_session(name="my-agent")
def run_agent(question: str):
    @trace_llm(model="gpt-4")
    def ask_llm(prompt):
        return client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": prompt}]
        )
    
    response = ask_llm(question)
    return response.choices[0].message.content

# Run and automatically trace
result = run_agent("What is the capital of France?")

# Traces saved to .mudipu/traces/

Analyze with CLI

# View health metrics
mudipu health .mudipu/traces/session_xyz.json

# See statistics
mudipu stats .mudipu/traces/session_xyz.json

# Generate visualization
mudipu health .mudipu/traces/session_xyz.json --visualize

📊 Context Health Metrics

Mudipu's unique health metrics help detect agent inefficiencies:

Metric What it detects Score Range
Relevance Off-topic context 0.0 - 1.0
Duplicate Ratio Repeated information 0.0 - 1.0
Tool Loops Repeated tool calls 0.0 - 1.0
Drift Goal misalignment 0.0 - 1.0
Novelty Progress tracking 0.0 - 1.0
Overall Health Combined score 0.0 - 1.0

Example output:

╭───────────────────────────────────────────────────╮
│ Session Health: 0.687 🟡 MODERATE                 │
│                                                   │
│ ├─ Context Growth: +58.1 tokens/turn              │
│ ├─ Drift Score: 0.024 ✓                           |
│ ├─ Loop Score: 0.333 ⚠️                           │
│ ├─ Progress: 0.333                                │
│ └─ Effectiveness: 0.700                           │
│                                                   │
│ ⚠️  Tool loops detected                           │
╰───────────────────────────────────────────────────╯

👉 Learn more about health metrics

📖 Documentation

🎯 Use Cases

  • Debug agent loops - Detect when your agent gets stuck
  • Optimize context - Identify redundant information
  • Track costs - Monitor token usage and expenses
  • Improve quality - Measure goal alignment over time
  • Analyze traces - Understand agent behavior patterns

🛠️ Architecture

Mudipu is designed to be:

  1. Local-first: All data stays on your machine
  2. Lightweight: Minimal performance overhead
  3. Framework-agnostic: Works with any LLM library
  4. Extensible: Add custom metrics and exporters
Your Agent Code
    ↓
[Mudipu Decorators]
    ↓
[Trace Capture]
    ↓
┌──────┴──────┬──────────┐
↓             ↓          ↓
Local JSON   HTML    Analysis CLI

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

📝 License

MIT License - see LICENSE for details.

⭐ Acknowledgments

Built with:


Metadata

Release files for mudipu 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mudipu 1.1.0
File Size Uploaded Provenance Actions
mudipu-1.1.0.tar.gz 55.1 kB Without provenance Details for mudipu-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mudipu 1.1.0
File Interpreter ABI Platform Actions
mudipu-1.1.0-py3-none-any.whl Python 3 none any Details for mudipu-1.1.0-py3-none-any.whl

Total release size: 105.1 kB

Release files / mudipu-1.1.0.tar.gz

Download URL mudipu-1.1.0.tar.gz
Size 55.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c2f30745962ba401a6f7731b64ea4d2fd9cb2965094cd11e9919f5333029174d
BLAKE2b-256 checksum
How to use checksums
5a1c600904663f8ffb8c0a445e09489d30931cbec08ff9dd94fc6302dfdfdbc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / mudipu-1.1.0-py3-none-any.whl

Download URL mudipu-1.1.0-py3-none-any.whl
Size 50.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be349fed678ea0ae0fbbd9d193a48e85a9f91edcb2b4ac9096b16552beb02481
BLAKE2b-256 checksum
How to use checksums
0c1124c6d8e5b2f61cee273223ad3f4d62201217ee98a93d38685d145383f6d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for mudipu 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page