Skip to main content

AgentQ SDK — agent observability for Python.

Project description

AgentQ SDK

A Python SDK for instrumenting AI agents with observability. Traces agent runs, LLM calls, and tool invocations, sending data to an AgentQ server via OpenTelemetry.

Installation

pip install agentq

For auto-instrumentation of specific LLM providers, install them alongside:

pip install agentq openai anthropic google-genai

Quick Start

import agentq

# Point to your AgentQ server
agentq.init(endpoint="http://localhost:3000")

# Auto-patch supported LLM libraries
agentq.instrument()

@agentq.agent(name="my-agent")
def run_task(prompt: str) -> str:
    # Any OpenAI/Anthropic/Gemini calls inside here are traced automatically
    response = openai.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": prompt}],
    )
    return response.choices[0].message.content

Features

  • @agent decorator -- Wraps functions and classes to create traced runs with input/output capture
  • Auto-instrumentation -- Monkey-patches OpenAI, Anthropic, and Google Gemini to trace every LLM call
  • Session tracking -- Group related runs into sessions with the session context manager
  • Nested spans -- Nested @agent calls and manual track_agent/track_llm/track_tool spans
  • Celery integration -- Captures queue wait time for Celery tasks
  • OpenTelemetry native -- Built on OpenTelemetry, compatible with any OTLP endpoint

API Reference

agentq.init(endpoint, headers, service_name)

Initialize the SDK. Call once at startup.

  • endpoint -- OTLP HTTP base URL (e.g. http://localhost:3000). Falls back to OTEL_EXPORTER_OTLP_ENDPOINT.
  • headers -- Extra headers for OTLP requests (e.g. {"Authorization": "Bearer sk-xxx"}).
  • service_name -- Value for the service.name resource attribute (default: "agentq").

agentq.instrument()

Activate auto-instrumentation for OpenAI, Anthropic, Google Gemini, and Celery. Safe to call even if libraries aren't installed.

@agentq.agent(name, entry_method, description, version, metadata)

Decorator for functions or classes. Creates a traced run for each invocation.

For classes, entry_method specifies which method(s) to instrument (default: "execute").

agentq.session(name, session_id, run_id, metadata)

Context manager that groups runs into a session:

with agentq.session(name="user-chat"):
    run_task("Hello")
    run_task("Follow up")

Manual Span Context Managers

with agentq.track_agent("sub-agent") as span:
    ...

with agentq.track_llm("gpt-4") as span:
    ...

with agentq.track_tool("web-search") as span:
    ...

License

MIT

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

agentq-0.1.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

agentq-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agentq-0.1.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agentq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 36123352d52353e3919b2c8cb6e1cccdd8a311aa5a9f42ca18ddbb789d71c639
MD5 66c1a5d8ad111ac3e3c823cf2e6c5c71
BLAKE2b-256 92b4920fee402a50785fa566df8b4c121997113462b4a5d05d15be714bd3ddcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentq-0.1.0.tar.gz:

Publisher: publish-sdk.yml on ryandao/agentq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: agentq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agentq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6ba590ae59742c0dea61b7f6da328bbf96f1700700bfbc361673edf1c64dcbd
MD5 a78c2826a56d2b193d37fb6f630a0a32
BLAKE2b-256 a423a9fa617222286f11e6ed5dd2becf87a69cb8e03dfd937ef8b5d7aac4c330

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentq-0.1.0-py3-none-any.whl:

Publisher: publish-sdk.yml on ryandao/agentq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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