Skip to main content

Pattern-aware OpenTelemetry tracing for multi-agent LLM systems

Project description

pyagent-trace

Pattern-aware OpenTelemetry tracing for multi-agent LLM systems. Track costs, record interactions, debug with replay.

Install

pip install pyagent-trace              # Core (CostTracker, Recorder work without OTel)
pip install pyagent-trace[otel]        # With OpenTelemetry spans

Components

  • CostTracker — Accumulate costs by pattern, agent, and model (no OTel required)
  • Recorder — Record all messages + LLM responses to JSONL for replay/debug
  • PatternSpanEmitter — Create OTel spans for pattern executions (requires OTel)
  • traced_pattern / traced_agent — Decorators for automatic tracing (requires OTel)
  • PyAgentAttributes — Custom pyagent.* attribute constants

Quick Example (no OTel required)

from pyagent_trace import CostTracker, Recorder

tracker = CostTracker()
tracker.record("debate", "bull_agent", "gpt-4o", 500, 200, 0.003)
print(f"Total: ${tracker.total_cost:.4f}")
print(f"By model: {tracker.by_model()}")

recorder = Recorder()
recorder.start("debate")
recorder.record_llm_call("bull", messages, "Bull case: ...")
recorder.end("Final decision")
recorder.save("traces/debug.jsonl")

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

pyagent_trace-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

pyagent_trace-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file pyagent_trace-0.1.0.tar.gz.

File metadata

  • Download URL: pyagent_trace-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pyagent_trace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 117cd6923ead988b848dfc048b5dabccf1b017e7244b6573c2a3bce44a12da81
MD5 3ca89692f33d1af86bf2654989801979
BLAKE2b-256 de557c1cf2b3eb440f6b672312be8492c818e7311707c4614461a728f0171696

See more details on using hashes here.

File details

Details for the file pyagent_trace-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyagent_trace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pyagent_trace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a2c8e52cbd5a4add53c0b862a7a92b347e8d71170aaa8dc099dadb3a2c63f6
MD5 bd6f5ffb971cfe02b8760d94418ed189
BLAKE2b-256 b481589fdc58c4f173d3006f6e2ded7a13c11c910d3cffe42563671feaaedef9

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