[integrations][java][python] Preserve Watsonx finish_reason in extra_args - #1113
Open
Ashfaqbs wants to merge 1 commit into
Open
[integrations][java][python] Preserve Watsonx finish_reason in extra_args#1113Ashfaqbs wants to merge 1 commit into
Ashfaqbs wants to merge 1 commit into
Conversation
…args Fixes apache#1106 (Watsonx portion). The Anthropic portion is covered separately by apache#1107. Watsonx already emits the shared finish_reason vocabulary (stop/tool_calls/etc.), so the value is retained verbatim in extra_args["finish_reason"] instead of only being used for a log warning. A missing or JSON-null reason adds no key, matching the OpenAI/Azure OpenAI connection's existing behavior. Generated-by: Claude Code 2.1.226 (Claude Sonnet 5)
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.
Linked issue: #1106 (Watsonx portion; the Anthropic portion is covered separately by #1107)
Purpose of change
Watsonx's chat response already carries a
finish_reasonin the shared OpenAI-compatible vocabulary (stop,tool_calls, etc.), but the connection only used it to emit a log warning and never surfaced it to callers. This preserves it verbatim inextra_args["finish_reason"], mirroring the existing OpenAI/Azure OpenAI connection behavior, for both the Java and Python connections.extra_args["finish_reason"], including values outsidestop/tool_calls.Tests
WatsonxChatModelConnectionTest— added 4 tests covering a documented reason, an unrecognized/vendor-specific reason stored verbatim, absentfinish_reasonmember, JSON-nullfinish_reason, and a reason captured without usage metadata present.mvn test -Dtest=WatsonxChatModelConnectionTest→ 24 passed.test_watsonx_chat_model.py— added 2 tests (unknown reason verbatim, no key whenNone) and assertedfinish_reasonin the existing mocked-chat test.pytest -m "not integration"→ 14 passed.mvn spotless:checkandruff check/ruff format --diffboth clean on the touched files.API
No public API signature changes; adds a new, optional key to the existing
extra_argsmetadata map returned by both connections.Documentation
doc-neededdoc-not-neededdoc-includedWas this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code 2.1.226 (Claude Sonnet 5)