Skip to content

Release/1.3.0 - #2253

Closed
Maria Tigina (tiginamaria) wants to merge 6 commits into
release/1.2.0from
release/1.3.0
Closed

Maria Tigina (tiginamaria) wants to merge 6 commits into
release/1.2.0from
release/1.3.0

Conversation

@tiginamaria

Copy link
Copy Markdown
Collaborator

Describe what this PR changes and why.

BREAKING:
*

DEPRECATED:
*

closes

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants