Repository navigation
Release/1.3.0 - #2253
Closed
Maria Tigina (tiginamaria) wants to merge 6 commits into
Closed
Release/1.3.0#2253Maria Tigina (tiginamaria) wants to merge 6 commits into
Maria Tigina (tiginamaria) wants to merge 6 commits into
Conversation
The Langfuse span adapter drops the assistant text of a Gemini response.
Google sends a Reasoning part that carries only a signature, with empty
content, next to the real Text part of the same assistant message.
`LangfuseSpanAdapter` checks its branches in order and takes the
reasoning branch first. It joins that empty content into an empty string
and writes the result as `gen_ai.completion.0.content`. The same branch
also skipped `finish_reason`, because only the last branch wrote it.
The fix keeps reasoning parts that carry content, and writes
`finish_reason` in every branch.
Measured on a real agent run against `gemini-3.8-flash`. Before the fix,
every response that finished with `stop` arrived in Langfuse as
`{"role": "assistant", "content": ""}`. After the fix, all 27 such
responses in the run carried their text.
`LangfuseSpanAdapterTest` gets a regression test that builds the message
shape Google sends, with an empty Reasoning part in front of the Text
part. It fails without the fix.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
…2249) `GoogleUsageMetadata` never read `cachedContentTokenCount`, so a cache hit stayed invisible to callers. Gemini reports that field when a prompt hits an implicit or an explicit cache. Without it `ResponseMetaInfo` reports the full prompt size, and nothing tells the caller which part of the prompt came from the cache, so any cost calculation on top of koog counts the whole prompt. This adds the field to `GoogleUsageMetadata` and carries it into `ResponseMetaInfo.metadata` under the same name, in the streaming path and in the non-streaming one. That is the route the Anthropic and Bedrock clients already use for their own cache token counts, so the value also reaches the OpenTelemetry attribute `gen_ai.response.metadata`. Measured on one agent run against `gemini-3.8-flash`: 29 of 54 calls reported a cache hit, 687,603 prompt tokens in total, none of them visible before. `GoogleLLMClientTest` gets a test that feeds a usage payload with `cachedContentTokenCount` through the client and asserts that the value reaches `metaInfo.metadata`. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR changes and why.
BREAKING:
*
DEPRECATED:
*
closes