I3eka opened a new pull request, #44492: URL: https://github.com/apache/superset/pull/44492
### SUMMARY Treat an AI completion stopped by its output token budget as incomplete, preserving the text received instead of reporting success. The streaming adapters discarded the provider's stop reason, and the runtime inferred `end_turn` whenever no tools were returned. The non-streaming runtime also ignored `max_tokens`. This can leave a sentence cut off in the stored transcript with a successful status. - Carry normalized stop reasons through the existing provider STOP event for both bundled adapters, retaining compatibility with providers that omit it. - Keep the partial answer, emit an actionable error, and use the existing error outcome/status. Do not dispatch tools from a capped completion or retry it automatically. - Do not try to parse incomplete OpenAI-compatible tool arguments after `finish_reason=length`. - Keep failed replies visibly incomplete when reopening a conversation, using the existing message status rather than changing the database schema. Depends on #42805, at `0e4a15cca1c5be2b7e68d609a9062f5e51193024`. This draft deliberately inherits that unmerged AI base. The focused fix is [one commit](https://github.com/I3eka/superset/commit/6af92f3d61bb9aa6f61fc0707ef87552e0e803ff); the full comparison with Apache master includes the base AI implementation. Please review the focused commit until that dependency lands. This is separate from #43135 (agent step budget) and #43237 (tool-result truncation). @sadpandajoe, this is another isolated follow-up to the AI base you reviewed. It changes truncation handling only; no deployment token limits, provider/model selection, automatic continuation, or credentials are included. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Before: a token-limited answer can be cut off mid-sentence yet marked complete, with no indication that the model stopped early. After: the text remains visible with an output-token-limit explanation during the run and an incomplete-run notice after reopening. Normal completed replies are unchanged. Covered by panel tests; no private conversation screenshot is published. ### TESTING INSTRUCTIONS - Backend AI unit tests: 710 passed, without any SDK network call or model credential. - Panel, stream-reader, and conversation-hook tests: 48 passed. Tests cover partial text plus the live warning and the reopened error-status transcript. - Regression cases cover both runtime modes, with/without text, with/without tools, stop reasons from both adapters, trailing usage frames, and truncated tool JSON. - Changed-file mypy, Ruff, pylint, formatting, frontend lint, custom rules, and stylelint pass. Targeted TypeScript retains the same nine errors independently reproduced on the unmodified #42805 parent with this environment's current frontend dependencies/generated declarations; none is introduced by this commit. - Required `pre-commit run --all-files` completed in an isolated checkout. Both mypy hooks, pylint, custom rules, stylelint, metadata/feature-flag validation, and security workflow checks pass. The full baseline still fails unrelated oxfmt/oxlint/Ruff checks, docs lint without Yarn, Helm docs without its executable, and full frontend typing with missing/out-of-date generated declarations. Auto-fixes from that checkout are not included here. Manual check: configure a small `AI_LLM_PROVIDER_CONFIG['max_output_tokens']`, ask for an answer that exceeds it, and verify partial text plus an incomplete-response warning, failed persisted message status, and no automatic follow-up call. Reopen the conversation and verify the incomplete notice remains. Then ask for a short answer that finishes normally and verify it has no warning. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [x] Required feature flags: `AI_ASSISTANT` - [x] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
