Pydantic AI capability for the Grafana Agent Observability Python SDK
Project description
Grafana AI Observability Python Framework Module: Pydantic AI
agento11y-pydantic-ai provides an AbstractCapability implementation that maps Pydantic AI lifecycle hooks into Sigil 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agento11y_pydantic_ai-0.10.0.tar.gz.
File metadata
- Download URL: agento11y_pydantic_ai-0.10.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7a0c0278d2e732b7c4a2f44aaf755de9bed62fa5261aa31c4aedfb2402178f6
|
|
| MD5 |
85ba1727ba6dceae778dd64c703c70d1
|
|
| BLAKE2b-256 |
d0655e087924baccaa5915442875691459b54fa35a18a9a998979e63b525c33d
|
Provenance
The following attestation bundles were made for agento11y_pydantic_ai-0.10.0.tar.gz:
Publisher:
python-sdks-publish.yml on grafana/agento11y
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agento11y_pydantic_ai-0.10.0.tar.gz -
Subject digest:
c7a0c0278d2e732b7c4a2f44aaf755de9bed62fa5261aa31c4aedfb2402178f6 - Sigstore transparency entry: 2212053037
- Sigstore integration time:
-
Permalink:
grafana/agento11y@a4e0bb2da205e2db40e7668df4e343263872cb3a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/grafana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdks-publish.yml@a4e0bb2da205e2db40e7668df4e343263872cb3a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file agento11y_pydantic_ai-0.10.0-py3-none-any.whl.
File metadata
- Download URL: agento11y_pydantic_ai-0.10.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0006b200f9e03befd8a2570a1f8c1401a5ace3648469d687d8ec50614df7e8fa
|
|
| MD5 |
b1d7b9aa2ed04292bffe5f4036b9d7e3
|
|
| BLAKE2b-256 |
13d1f32bd9464b0b8a692118197f76ac68f63c38bb6f5a5dfb20ac8ae4e73797
|
Provenance
The following attestation bundles were made for agento11y_pydantic_ai-0.10.0-py3-none-any.whl:
Publisher:
python-sdks-publish.yml on grafana/agento11y
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agento11y_pydantic_ai-0.10.0-py3-none-any.whl -
Subject digest:
0006b200f9e03befd8a2570a1f8c1401a5ace3648469d687d8ec50614df7e8fa - Sigstore transparency entry: 2212053057
- Sigstore integration time:
-
Permalink:
grafana/agento11y@a4e0bb2da205e2db40e7668df4e343263872cb3a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/grafana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-sdks-publish.yml@a4e0bb2da205e2db40e7668df4e343263872cb3a -
Trigger Event:
workflow_dispatch
-
Statement type: