You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "emecii (via GitHub)" <gi...@apache.org> on 2026/09/06 07:27:06 UTC
[I] [integrations] Preserve finish_reason for Anthropic and Watsonx responses [flink-agents]
emecii opened a new issue, #1106:
URL: https://github.com/apache/flink-agents/issues/1106
### Motivation
Follow-up to #936 and merged #1040. The shared response path now checks `finish_reason`, but Anthropic still has the capture TODO identified in #936; Watsonx parses a reason without preserving it in message metadata. Those providers therefore do not consistently participate in the shared handling.
#1040 explicitly checks the common path before text, structured output, or tool dispatch, and its approval acknowledges that design. This proposal follows that accepted behavior rather than moving the gate.
### Proposed scope
Capture `finish_reason` in the Java and Python Anthropic and Watsonx connection responses, preserving content and the existing provider-specific content blocks.
For Anthropic, propose `max_tokens` → `length`, `end_turn`/`stop_sequence` → `stop`, and `tool_use` → `tool_calls`. Preserve unrecognized reasons, including `model_context_window_exceeded` and `refusal`, verbatim for now. Mapping context exhaustion to `length` would currently tell users to increase output tokens, which may be the wrong remedy; treating a refusal as `content_filter` would add a new rejection decision.
For Watsonx, retain its reported reason verbatim. Missing reasons should not add a metadata key. Keep finish-reason metadata out of outbound provider requests, while preserving Anthropic content-block round trips.
### Validation and scope decision
Use SDK response fixtures and Java/Python tests for capture with and without usage, missing and unknown reasons, outbound serialization, and the existing shared rejection/error-strategy path. No live-provider performance or model-quality claims are proposed.
Does this mapping and scope have committer support? In particular, should the two Anthropic reasons above remain native until shared diagnostics and rejection semantics are decided? A local implementation prototype exists, but no PR is being represented as approved by this issue.
Prepared with OpenAI Codex assistance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [integrations] Preserve finish_reason for Anthropic and Watsonx responses [flink-agents]
Posted by "CodeTrainerMan (via GitHub)" <gi...@apache.org>.
CodeTrainerMan commented on issue #1106:
URL: https://github.com/apache/flink-agents/issues/1106#issuecomment-5734456892
Update before I write any code: I checked `main` and the Watsonx portion is **already done**, so I am withdrawing my claim on it.
#1113 (`[integrations][java][python] Preserve Watsonx finish_reason in extra_args`, by @Ashfaqbs, merged 2026-09-14) covers both sides, and matches the scope described here:
* Java - `WatsonxChatModelConnection.parseResponse()` writes `extraArgs["finish_reason"]` verbatim, with tests for `stop`, an unrecognized vendor reason, an absent `finish_reason` member, an explicit JSON `null`, and for capture working independently of the usage branch.
* Python - `WatsonxChatModelConnection.chat()` does the same, with tests for verbatim capture and for the key being absent when the provider reports none.
* Neither `convertMessages` (Java) nor `convert_to_watsonx_messages` (Python) carries `extra_args` into the outbound payload, so the metadata stays out of the request.
The issue body still states "Watsonx remains an independent, unstarted follow-up", which is what I based my claim on. It would help the next reader if the body pointed at #1113 and marked the Watsonx part closed.
One observation on the Anthropic half while I was reading #1107 against the mapping proposed here: #1107 keeps `end_turn` as `end_turn`, whereas this issue proposed `end_turn`/`stop_sequence` ? `stop`. Preserving the provider vocabulary looks like a deliberate narrowing, and the "preserve unrecognized reasons" wording here can be read either way - so I am not filing anything, but if that was intentional it may be worth noting in the issue so the Anthropic portion also reads as settled.
Happy to pick up something else; I will look at the other open issues instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [integrations] Preserve finish_reason for Anthropic and Watsonx responses [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on issue #1106:
URL: https://github.com/apache/flink-agents/issues/1106#issuecomment-5770375523
Thanks for offering to help @CodeTrainerMan. Both portions have already been merged: Anthropic in #1107 and Watsonx in #1113. Sorry—the issue description was outdated and still marked Watsonx as unstarted. No additional implementation is needed for this issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [integrations] Preserve finish_reason for Anthropic and Watsonx responses [flink-agents]
Posted by "CodeTrainerMan (via GitHub)" <gi...@apache.org>.
CodeTrainerMan commented on issue #1106:
URL: https://github.com/apache/flink-agents/issues/1106#issuecomment-5734433265
Thanks for the detailed breakdown. I would like to take the **Watsonx** portion.
It is independent from the Anthropic mapping already submitted in #1107, and the scope you described is unambiguous, so I plan to follow it exactly:
* retain the reason reported by the provider verbatim (Watsonx already emits the shared vocabulary, so no mapping table is needed);
* add no metadata key when the provider reports no finish reason;
* keep the finish-reason metadata out of the outbound provider payload;
* cover both the Java and Python Watsonx chat model connections, with tests.
Before I write code I have two questions so the first PR lands in the right shape:
1. Naming: should the metadata key match the one #1107 introduced for Anthropic (I will read that patch and follow it) or is there a shared constant for finish reason that both providers are expected to use?
2. Does Watsonx need to go through the shared response path from #1040 the same way #1107 does for Anthropic, or is it wired up differently?
I will keep the PR scoped to Watsonx only and wait for your ack before opening it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [integrations] Preserve finish_reason for Anthropic and Watsonx responses [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 closed issue #1106: [integrations] Preserve finish_reason for Anthropic and Watsonx responses
URL: https://github.com/apache/flink-agents/issues/1106
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org