Cost-aware observability for AI agents: ingest structured traces, enforce in-memory budgets before the next LLM call, build causal graphs, and explore runs in a Next.js dashboard.
MeshFix/
├── mantis/ # FastAPI API, RCA engine, Celery worker
├── mantis-sdk/ # Python SDK (spans, cost math, BudgetGuard)
├── frontend/ # Next.js dashboard
├── examples/ # Runnable integration samples
└── docker-compose.yml
cd mantis
python -m venv .venv
# Windows: .venv\Scripts\activate
pip install -r requirements.txt pydantic-settings
pip install -e ../mantis-sdk
cp .env.example .env
uvicorn main:app --reload --port 8080Bootstrap a project and API key:
curl -s -X POST http://127.0.0.1:8080/v1/projects \
-H "Content-Type: application/json" \
-H "X-Admin-Secret: YOUR_MANTIS_ADMIN_SECRET" \
-d '{"name":"demo"}'Use the returned api_key (mt_...) for ingest and the SDK.
cp mantis/.env.example mantis/.env
docker compose up --build| Service | URL |
|---|---|
| API | http://localhost:8080 |
| Dashboard | http://localhost:3000 |
| Metrics | http://localhost:8080/metrics |
pip install -e ./mantis-sdkfrommantis_sdkimportMantisClient, spanclient=MantisClient(api_key="mt_...", base_url="http://127.0.0.1:8080")
withclient.trace(agent_id="refund-bot", metadata={"env": "dev"}) assession:
withspan("fetch_ticket", input={"ticket_id": "TKT-1"}) asstep:
step.set_output({"ok": True})See examples/ for OpenAI, LangChain, and multi-agent patterns.
Package: mantis-sdk (README)
| Feature | Module |
|---|---|
| Client + background flush | MantisClient |
| Manual spans | span(), trace_session() |
| Integer cost math | compute_cost_microdollars() |
| OpenAI | mantis_sdk.openai.wrap_openai |
| LangChain | MantisLangChainHandler |
Environment: MANTIS_API_KEY, MANTIS_BASE_URL (default http://127.0.0.1:8080).
cd frontend
npm install
echo"NEXT_PUBLIC_MANTIS_API_URL=http://127.0.0.1:8080"> .env.local
npm run devOpen http://localhost:3000 — paste your API key in Settings, then browse Runs.
All tenant routes require X-API-Key: mt_... or Authorization: Bearer mt_....
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /health | — | Liveness |
| GET | /ready | — | DB + fixture readiness |
| GET | /metrics | — | Prometheus metrics |
| POST | /v1/projects | X-Admin-Secret | Create project + initial API key |
| POST | /v1/ingest | API key | Ingest agent trace JSON |
| GET | /v1/runs/{id}/graph | API key | Parent-child run DAG |
| POST | /v1/projects/{id}/security-scans | API key | Enqueue AgentShield scan |
cd mantis-sdk && python -m pytest tests/ -q
cd mantis && python -m pytest tests/ -qCI runs the same suites on push via .github/workflows/ci.yml.
Hackathon / demo codebase — adjust licensing before commercial use.