Summary
The Gemini (genai) integration does not capture the ThinkingConfig request parameter in span metadata, and does not map the thoughtsTokenCount response metric to a standard metric name. Thinking/reasoning is an official, documented Gemini 2.5+ feature that is already used within this repo's ADK integration tests.
What is missing
1. ThinkingConfig not captured from request
In trace/contrib/genai/generatecontent.go (lines 48–81), the metadata and generation config fields are explicitly listed:
metadataFields := []string{
"model", "systemInstruction", "tools", "toolConfig", "safetySettings", "cachedContent",
}
// ...
configFields := []string{
"temperature", "topP", "topK", "candidateCount", "maxOutputTokens",
"stopSequences", "responseMimeType", "responseSchema",
}
thinkingConfig is absent from both lists. When a user sets ThinkingConfig with IncludeThoughts, ThinkingBudget, or ThinkingLevel, these parameters are silently dropped from the span metadata. Other comparable generation parameters (temperature, topP, maxOutputTokens) are all captured.
2. thoughtsTokenCount not mapped to a standard metric name
In parseUsageTokens (lines 167–196), four Gemini token fields are explicitly mapped:
| Gemini field |
Mapped metric |
promptTokenCount |
prompt_tokens |
candidatesTokenCount |
completion_tokens |
totalTokenCount |
tokens |
cachedContentTokenCount |
prompt_cached_tokens |
thoughtsTokenCount falls through to the default case and gets converted to thoughts_token_count via camelToSnake. While technically captured, it is not mapped to a recognizable standard metric name (e.g., completion_reasoning_tokens as used by the OpenAI integration for similar reasoning token tracking).
3. This repo already uses ThinkingConfig
The ADK integration tests in trace/contrib/adk/golden_test.go (lines 562–569) already exercise ThinkingConfig:
ThinkingConfig: &genai.ThinkingConfig{
IncludeThoughts: true,
ThinkingBudget: &thinkingBudget,
},
This confirms the feature is actively used with Gemini models in this SDK's ecosystem.
Braintrust docs status
Extended thinking / reasoning token tracking is not explicitly documented in Braintrust docs. The OpenAI integration in this SDK captures completion_reasoning_tokens for reasoning models. Status: unclear (no explicit Braintrust docs for Gemini thinking tokens, but analogous OpenAI reasoning tokens are captured).
Upstream sources
- Gemini thinking docs: https://ai.google.dev/gemini-api/docs/thinking
- Supported on Gemini 2.5 (Flash, Pro, Flash-Lite) and Gemini 3 series
ThinkingConfig fields: IncludeThoughts (bool), ThinkingBudget (int32), ThinkingLevel (string)
- Response
usageMetadata includes thoughtsTokenCount for reasoning token usage
Braintrust docs sources
Local repo files inspected
trace/contrib/genai/generatecontent.go — metadata field lists and parseUsageTokens
trace/contrib/openai/traceopenai.go — parseUsageTokens maps completion_reasoning_tokens (precedent)
trace/contrib/adk/golden_test.go — ThinkingConfig already in use
trace/contrib/genai/tracegenai_test.go — no thinking-related tests
Summary
The Gemini (
genai) integration does not capture theThinkingConfigrequest parameter in span metadata, and does not map thethoughtsTokenCountresponse metric to a standard metric name. Thinking/reasoning is an official, documented Gemini 2.5+ feature that is already used within this repo's ADK integration tests.What is missing
1.
ThinkingConfignot captured from requestIn
trace/contrib/genai/generatecontent.go(lines 48–81), the metadata and generation config fields are explicitly listed:thinkingConfigis absent from both lists. When a user setsThinkingConfigwithIncludeThoughts,ThinkingBudget, orThinkingLevel, these parameters are silently dropped from the span metadata. Other comparable generation parameters (temperature, topP, maxOutputTokens) are all captured.2.
thoughtsTokenCountnot mapped to a standard metric nameIn
parseUsageTokens(lines 167–196), four Gemini token fields are explicitly mapped:promptTokenCountprompt_tokenscandidatesTokenCountcompletion_tokenstotalTokenCounttokenscachedContentTokenCountprompt_cached_tokensthoughtsTokenCountfalls through to the default case and gets converted tothoughts_token_countvia camelToSnake. While technically captured, it is not mapped to a recognizable standard metric name (e.g.,completion_reasoning_tokensas used by the OpenAI integration for similar reasoning token tracking).3. This repo already uses ThinkingConfig
The ADK integration tests in
trace/contrib/adk/golden_test.go(lines 562–569) already exerciseThinkingConfig:This confirms the feature is actively used with Gemini models in this SDK's ecosystem.
Braintrust docs status
Extended thinking / reasoning token tracking is not explicitly documented in Braintrust docs. The OpenAI integration in this SDK captures
completion_reasoning_tokensfor reasoning models. Status: unclear (no explicit Braintrust docs for Gemini thinking tokens, but analogous OpenAI reasoning tokens are captured).Upstream sources
ThinkingConfigfields:IncludeThoughts(bool),ThinkingBudget(int32),ThinkingLevel(string)usageMetadataincludesthoughtsTokenCountfor reasoning token usageBraintrust docs sources
Local repo files inspected
trace/contrib/genai/generatecontent.go— metadata field lists andparseUsageTokenstrace/contrib/openai/traceopenai.go—parseUsageTokensmapscompletion_reasoning_tokens(precedent)trace/contrib/adk/golden_test.go— ThinkingConfig already in usetrace/contrib/genai/tracegenai_test.go— no thinking-related tests