Skip to content

fix(models): propagate Anthropic finish reasons#5399

Open
MukundaKatta wants to merge 3 commits intogoogle:mainfrom
MukundaKatta:codex/adk-anthropic-finish-reason
Open

fix(models): propagate Anthropic finish reasons#5399
MukundaKatta wants to merge 3 commits intogoogle:mainfrom
MukundaKatta:codex/adk-anthropic-finish-reason

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

  • populate LlmResponse.finish_reason for non-streaming Anthropic responses using the existing stop-reason mapper
  • capture message_delta.stop_reason during streaming and set it on the final aggregated response
  • map Anthropic pause_turn to STOP and refusal to SAFETY, and add regression tests for the helper and both response paths

Testing

  • python3 -m py_compile src/google/adk/models/anthropic_llm.py tests/unittests/models/test_anthropic_llm.py
  • python3 -m pytest tests/unittests/models/test_anthropic_llm.py -k "finish_reason or non_streaming_does_not_pass_stream_param or streaming_sets_finish_reason_from_message_delta" (fails during collection locally: ModuleNotFoundError: No module named anthropic)

@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Apr 19, 2026

Response from ADK Triaging Agent

Hello @MukundaKatta, thank you for creating this PR!

This PR is a bug fix. Could you please associate a GitHub issue with this PR? If there is no existing issue, could you please create one?

This information will help reviewers to review your PR more efficiently. Thanks!

@adk-bot adk-bot added the models [Component] Issues related to model support label Apr 19, 2026
@rohityan rohityan self-assigned this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] Issues related to model support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants