Grafana Agent Observability Python Framework Module: Pydantic AI
agento11y-pydantic-ai provides an AbstractCapability implementation that maps Pydantic AI lifecycle hooks into agento11y generation recorder lifecycles.
Installation
pip install agento11y agento11y-pydantic-ai
pip install pydantic-ai
Quickstart
from pydantic_ai import Agent
from agento11y import Client
from agento11y_pydantic_ai import create_agento11y_pydantic_ai_capability
client = Client()
capability = create_agento11y_pydantic_ai_capability(client=client, provider_resolver="auto")
agent = Agent("openai:gpt-4o", capabilities=[capability])
result = agent.run_sync("What is the weather?")
print(result.output)
client.shutdown()
End-to-end example (run + run_stream)
from pydantic_ai import Agent
from agento11y import Client
from agento11y_pydantic_ai import with_agento11y_pydantic_ai_capability
client = Client()
capabilities = with_agento11y_pydantic_ai_capability(
None,
client=client,
provider_resolver="auto",
agent_name="pydantic-ai-example",
agent_version="1.0.0",
)
agent = Agent("openai:gpt-4o-mini", capabilities=capabilities)
# Non-stream call -> SYNC generation mode.
result = agent.run_sync("Summarize why retry budgets matter.")
print(result.output)
# Stream call -> STREAM generation mode + TTFT tracking.
async def stream_example() -> None:
async with agent.run_stream("Give me three short reliability tips.") as stream:
async for chunk in stream.stream_text():
print(chunk, end="", flush=True)
print()
import asyncio
asyncio.run(stream_example())
client.shutdown()
Conversation mapping
Primary mapping is Pydantic AI run identity:
conversation_id/session_idfromctx.depsorctx.metadatathread_idfromctx.depsorctx.metadata- fallback
agento11y:framework:pydantic-ai:<run_id>
Metadata and lineage
- Required:
agento11y.framework.run_type - Optional:
agento11y.framework.run_id,agento11y.framework.parent_run_id,agento11y.framework.thread_id,agento11y.framework.event_id,agento11y.framework.component_name,agento11y.framework.retry_attempt
Provider resolver
Resolver order: explicit provider option -> callback payload -> model prefix inference -> custom.
Troubleshooting
- Provide stable
conversation_idviactx.depsorctx.metadatato avoid fragmented conversations. - If model aliases are custom, set explicit
provideron the handler. - Always call
client.shutdown()during teardown to flush buffered telemetry.
Metadata
Release files for agento11y-pydantic-ai 0.23.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agento11y_pydantic_ai-0.23.0.tar.gz | 13.0 kB | With provenance | Details for agento11y_pydantic_ai-0.23.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agento11y_pydantic_ai-0.23.0-py3-none-any.whl | Python 3 | none | any | Details for agento11y_pydantic_ai-0.23.0-py3-none-any.whl |
Total release size: 22.0 kB
Release files / agento11y_pydantic_ai-0.23.0.tar.gz
| Download URL | agento11y_pydantic_ai-0.23.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e9f667af048030ecd22046903f1135eae964c775b8b58e0185bba1632fd486e
|
|
BLAKE2b-256 checksum How to use checksums |
b41f05d7f2636aa096795faca15b6680dd1735a10d45e0a152ae48e1a3c9b1f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / agento11y_pydantic_ai-0.23.0-py3-none-any.whl
| Download URL | agento11y_pydantic_ai-0.23.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10c2d537c49203e87ae7a335f77e93f6602cc4f0657c845a62493fdca023cd89
|
|
BLAKE2b-256 checksum How to use checksums |
4346bfd9554310685d0e04864f24d0fcfdff4f3e4fc144251defeb97a9150fcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for agento11y-pydantic-ai 0.23.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for agento11y_pydantic_ai-0.23.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.