[bot] Google GenAI: Chat session API (`chats.create`, `send_message`) not instrumented in Python (documented as traced in JS)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 65/100
- Issue-Typ
- Feature
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- devtools, observability
Rechercherichtung
The issue is to add instrumentation for the Chat session API in the Google GenAI Python SDK. Start by examining the existing patchers in py/src/braintrust/integrations/google_genai/patchers.py and integration.py. Look at the upstream google/genai/chats.py to understand the Chat/AsyncChat classes and their send_message methods. The goal is to create a new patcher that captures session-level spans for chat lifecycle and history, similar to the JS/TS implementation. Test by running the existing integration tests and verifying that chat spans appear in traces.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
The google-genai Python SDK's Chat session API (client.chats.create(model=...) returning a Chat/AsyncChat with send_message()/send_message_stream()) has no dedicated instrumentation in this repo's Python integration. Braintrust's own docs confirm this capability is already designed and shipped for the legacy JS/TS SDK ("Chat spans (send_message, send_message_stream): message input and model as metadata") — it is simply missing from the Python integration.
What is missing
py/src/braintrust/integrations/google_genai/patchers.py and integration.py register patchers only for Models/AsyncModels (generate_content, generate_content_stream, embed_content, generate_images) and Interactions/GAOSInteractions (create/get/cancel/delete, sync and async). There is no patcher targeting google.genai.chats.Chats/AsyncChats/Chat/AsyncChat anywhere in the file, and no reference to chat, Chat, or send_message in tracing.py or patchers.py.
Verified against the pinned upstream version (google-genai==2.24.0, per py/uv.lock): Chat.send_message() does internally delegate to self._modules.generate_content(...) — i.e. it reuses the already-patched Models.generate_content path, so a generate_content span is still produced per turn. However, Chat/AsyncChat (subclass _BaseChat) separately maintains cross-turn conversation state — self._curated_history and self._comprehensive_history, updated via record_history() after every turn — that is invisible to any single generate_content span. There is no session-level span capturing the chat object's lifecycle, turn count, or curated-vs-comprehensive history divergence (e.g. when a turn is marked invalid and excluded from curated history sent to the model on subsequent turns).
Braintrust docs status: supported (JS/TS) / not_found (Python)
The Gemini integration page, Python section, documents only: content generation spans (generate_content/generate_content_stream), embedding spans (embed_content), image generation spans (generate_images), and interaction spans (interactions.create/get/cancel/delete). It contains zero mentions of chat, chats, send_message, or ChatSession in the Python section.
The same page's legacy-SDK section (for @google/generative-ai, JS/TS) explicitly documents: "Chat spans (send_message, send_message_stream): message input and model as metadata." This confirms Braintrust considers chat-session tracing a real, intended capability — it has just not been ported to the Python google-genai integration.
Upstream sources
google-genaiPython SDK,google/genai/chats.py(tagv2.24.0), classesChat/AsyncChat/_BaseChat, factoriesChats.create()/AsyncChats.create(): https://github.com/googleapis/python-genai/blob/v2.24.0/google/genai/chats.py- Google GenAI Chat documentation: https://ai.google.dev/gemini-api/docs/text-generation#chat
Local repo files inspected
py/src/braintrust/integrations/google_genai/integration.py(full file — patcher list)py/src/braintrust/integrations/google_genai/patchers.py(full file — noChat/chatspatcher)py/src/braintrust/integrations/google_genai/tracing.py(grepped for all top-levelclass/defnames andchat— no matches)py/uv.lock(confirms pinnedgoogle-genai==2.24.0)
- Vorherrschende Sprache
- Python
- Sterne
- 19
- Forks
- 17
- Ø Merge
- 1 T. 5 Std.
- Gemergte PRs (30 T.)
- 61
Entwicklungsumgebung
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus braintrustdata/braintrust-sdk-python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
braintrustdata/braintrust-sdk-python#797 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
braintrustdata/braintrust-sdk-python#774 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
braintrustdata/braintrust-sdk-python#798 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
braintrustdata/braintrust-sdk-python#787 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
braintrustdata/braintrust-sdk-python#786 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in braintrustdata/braintrust-sdk-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
gradio-app/gradio#13895 ·
Maintainer antworten meist innerhalb von 1 Tag
-
build-error
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
spack/spack-packages#6713 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Use issue templatesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
ActivityWatch/activitywatch#1464 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]: The ckg tool drops the return type of every decorated Python method in class search resultsOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
bytedance/trae-agent#483 ·
Maintainer antworten meist innerhalb von 1 Tag