Skip to main content

Open-source instrumentation SDK for Debrix — local-first AI Agent DevTools

Project description

debrix

Open-source instrumentation SDK for Debrix — local-first AI Agent DevTools.

Status: alpha (0.1.0a4). APIs may change.

Requires the Debrix desktop app running locally to receive traces (OTLP/HTTP on localhost:17418).

Source: goyal-prateek/debrix-sdk

Install

pip install debrix

Quick start

from debrix import configure, force_flush, trace_agent, trace_tool, trace_span, SpanKind

configure(batch=False)  # OTLP/HTTP → http://127.0.0.1:17418

@trace_agent
def run_agent(query: str) -> str:
    return research(query)

@trace_tool(name="search")
def research(query: str) -> str:
    with trace_span("complete", kind=SpanKind.LLM) as span:
        span.record_messages([
            {"role": "system", "content": "You are helpful."},
            {"role": "user", "content": query},
        ])
        answer = "..."
        span.record_response({
            "content": answer,
            "usage": {"input_tokens": 10, "output_tokens": 5},
        })
        return answer

run_agent("hello")
force_flush()  # flush OTLP *and* conversation payload uploads before exit

Decorators also work as context managers:

with trace_agent("planner") as span:
    with trace_tool("lookup"):
        ...

Public API

Symbol Purpose
configure() Install OTLP/HTTP exporter to Debrix (:17418)
force_flush() Flush OTLP spans + pending /v1/payloads uploads (call before short scripts exit)
trace_agent Agent boundary (decorator or with trace_agent("name"))
trace_tool Tool call span; records replay I/O + sequence index; consults Tool Mocker / Replay
trace_span Generic / LLM / custom span context manager
DebrixSpan.record_messages(...) Opt-in message payloads
DebrixSpan.record_response(...) Opt-in model output / tokens
MockableClient Opt-in MCP client wrapper for Tool Mocker (debrix.mcp)
MockToolError Raised when a mock rule returns error/timeout
SpanKind, Attr Semantic convention constants

Nested calls propagate via OpenTelemetry context. On exception, spans are marked ERROR with debrix.error.summary.

Tool Mocker & Deterministic Replay

When the Debrix desktop app is running, @trace_tool / MockableClient ask POST {otlp}/mocks/resolve before calling the real function.

  • Tool Mocker: rules from the app’s Tool Mocks panel → action: mock
  • Replay (tools only): armed Observe Replay → tools/MCP action: replay
  • Replay (tools + LLM stubs): same session with Tools + LLM; use debrix.llm.complete so pinned LLM calls resolve as action: replay (kind=llm)

If Debrix is down or times out (~200ms), the SDK passthrough to the real implementation.

from debrix.mcp import MockableClient
from debrix.llm import complete

client = MockableClient(real_mcp_client, server="demo-db")
result = await client.call_tool("query", {"sql": "select 1"})

answer = complete(
    messages,
    call=lambda msgs: my_provider(msgs),  # (content, usage, model)
)

Stubbed spans set debrix.stub to mock (Tool Mocker) or replay (Deterministic Replay).

Develop

uv sync --group dev
uv run pytest

License

MIT

Release

Tag on main to publish to PyPI (GitHub Actions):

git tag -a v0.1.0a4 -m "debrix 0.1.0a4"
git push origin v0.1.0a4

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

debrix-0.1.0a4.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

debrix-0.1.0a4-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file debrix-0.1.0a4.tar.gz.

File metadata

  • Download URL: debrix-0.1.0a4.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for debrix-0.1.0a4.tar.gz
Algorithm Hash digest
SHA256 2af08b688bc717e8d22754af3686de11f331a898e02331b0408485949014e182
MD5 a2ddc7302e66a660efbe60c5aa15bb49
BLAKE2b-256 c7c55d0b86f3aea037d4de76622652435980256dab9566098267e779c6bce208

See more details on using hashes here.

File details

Details for the file debrix-0.1.0a4-py3-none-any.whl.

File metadata

  • Download URL: debrix-0.1.0a4-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for debrix-0.1.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 0a707eb0495f99931fc5be43b85ba0f7bf6a1c089103e3b176805db73c9fde9c
MD5 efa37e40b491dd30042134c19da728bc
BLAKE2b-256 9c1e2513731ef511d6e99697be0a2f8abab3d2bb2d6150713adfc7eeb201a0eb

See more details on using hashes here.

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