import httpx, threading, time
def muster_emit(job_id, checks, token_input=None, token_output=None, model=None, latency_ms=None):
"""Fire-and-forget. Covers: correctness checks + cost + latency in one call."""
def _send():
try:
httpx.post(
f"https://backend.getmuster.io/api/v1/jobs/{job_id}/quality",
json={
"agent_id": "your-agent-name", # ← replace with your agent name
"job_id": job_id,
"overall_passed": all(c["passed"] for c in checks),
"checks": checks,
"token_input": token_input, # from LLM response.usage
"token_output": token_output,
"model": model,
"latency_ms": latency_ms,
},
timeout=2.0,
)
except Exception:
pass # never block your agent
threading.Thread(target=_send, daemon=True).start()