Skip to content

fix(telemetry): report tool_call finish reason for function-call turns - #8428

Open
GermanGerken wants to merge 2 commits into
google:mainfrom
GermanGerken:fix/telemetry-tool-call-finish-reason
Open

GermanGerken wants to merge 2 commits into
google:mainfrom
GermanGerken:fix/telemetry-tool-call-finish-reason

Conversation

@GermanGerken

Copy link
Copy Markdown

Fixes #8425.

Problem

Gemini reports STOP for a model turn that ends in a function call, and the OpenAI integration maps tool_calls to STOP too. GenAI telemetry therefore published gen_ai.response.finish_reasons = ["stop"] (and finish_reason: "stop" in output messages) for tool-call turns, although the GenAI semantic conventions name this case tool_call.

Change

  • _finish_reason.reports_tool_call(): true when the finish reason is STOP, the content contains a function_call part, and the semconv-aligned schema is active.
  • Used in _experimental_semconv._to_finish_reason (response attributes and output messages) and in tracing.trace_inference_result.
  • The legacy schema (ADK_TELEMETRY_SCHEMA_VERSION_OPT_IN=1) keeps reporting stop.

Tests

Added to tests/unittests/telemetry/test_experimental_semconv.py:

  • a STOP turn with a function call reports tool_call;
  • the same turn on the legacy schema reports stop.

Gemini and the OpenAI integration report STOP for a model turn that ends
in a function call, so GenAI telemetry published finish reason "stop".
Under the semconv-aligned schema, report "tool_call" when a STOP turn's
content contains a function call. The legacy schema keeps "stop".

Fixes google#8425
…all turn

Gemini reports STOP for a model turn that ends in a function call, and the
OpenAI integration maps tool_calls to STOP, so telemetry recorded such turns
as "stop". The GenAI semantic conventions name this case "tool_call".

With the semconv-aligned schema (2), a STOP turn whose content has a
function_call part is now reported as "tool_call" in
gen_ai.response.finish_reasons and in gen_ai.output.messages. The legacy
schema (1) keeps reporting "stop".

Fixes google#8425
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.

GenAI telemetry reports finish reason "stop" for model turns that end in a function call

1 participant