SEZ9 opened a new pull request, #13414: URL: https://github.com/apache/seatunnel/pull/13414
Yes — glad to contribute this to Apache SeaTunnel. Closes #13413. ### What Problem Does This PR Solve? `seatunnel-cli`'s OpenAI-compatible provider collapsed every `finish_reason` except `tool_calls` into `end_turn`, in both the streaming and the non-streaming path. A response truncated at the output token limit was therefore indistinguishable from a completed one: `Orchestrator` carried on, parsed a config that was cut in half or absent entirely, and reported a generic `Failed to generate config.` with the real cause — the output budget — nowhere in the message. `content_filter` was flattened the same way. The same file also read the reasoning block only under `reasoning_content`, while vLLM's reasoning parser emits `reasoning` from 0.34 on. Against such a server the block was silently dropped, and for a server that requires reasoning to be replayed after a tool call that became a 400 on the next request — the exact failure `format_llm_error()` already carries a hint for. ### How Was This Patch Tested? `seatunnel-cli` test suite: **442 passed** (431 before, 11 added), `ruff check .` clean. I checked the new tests are load-bearing by reverting each change and confirming the matching tests go red, rather than only that they pass: | Reverted change | Result | | --- | --- | | collapse every finish reason to `end_turn` again | 6 failed | | read only `reasoning_content` again | 2 failed | | stop raising on truncation, return the empty turn | 2 failed | | nothing reverted | 18 passed | ### What Changed **Finish reasons are translated, not collapsed.** `finish_reason` now maps into the Bedrock Converse vocabulary the internal format already uses (`output.message.content` plus `stopReason`), so no new vocabulary is invented here: | `finish_reason` | internal `stopReason` | | --- | --- | | `stop` | `end_turn` | | `tool_calls` | `tool_use` | | `length` | `max_tokens` | | `content_filter` | `content_filtered` | | absent / unrecognised | `end_turn` | **A truncated turn with nothing usable now raises.** When the turn stopped at the limit with no text and no tool call there is nothing for the caller to act on, so both paths raise a new `TruncatedOutputError` instead of returning the empty turn, and `format_llm_error()` gained a matching hint (raise `max_tokens`, shorten the request, or disable thinking). A truncated turn that *did* produce partial content is reported as `max_tokens` and left for the caller to judge, so a usable short answer cannot be turned into an error by this change. **Either reasoning field name is accepted.** `_get_openai_reasoning()` tries `reasoning_content` then `reasoning`, first non-empty wins, so a server sending both does not get its reasoning duplicated. ### Compatibility - **No new or changed configuration options, and no changed defaults.** - **Callers are unaffected by the new stop reasons.** The only consumer of `stopReason` is `agents.py`, which compares against `"tool_use"` and treats everything else as a finished turn; `grep` confirms nothing compares against `"end_turn"` to decide success. Unknown values still become `end_turn`, so a server returning a value this table does not list behaves exactly as before. - **Behaviour changes in one direction only**: a call that previously returned an empty turn and failed later with a generic message now fails at the provider with an accurate one. No case that previously produced a config stops producing one. - `OrcaRouterProvider` and the Standard Compute provider added in #13205 both extend `OpenAIProvider` and inherit all of this. - `BedrockMantleProvider` speaks the OpenAI Responses API and has its own response handling; it is deliberately left alone rather than half-converted in this PR. ### Docs `docs/en/ai-cli/quickstart.md` and `docs/zh/ai-cli/quickstart.md` both gain a short "Reasoning models and output limits" subsection, since both facts are user-visible. I diffed every heading in both files against `dev` to confirm the edit added one heading and removed none. ### Check list * [x] Code changed are covered with tests, or it does not need tests for reason * [x] If any new Jar binary package adding in your PR, please add License Notice according [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md) — no new dependency * [x] If necessary, please update the documentation to describe the new feature * [x] If you are contributing the connector code, please check that the following files are updated — not a connector change 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
