atiaomar1978-hub commented on PR #24901: URL: https://github.com/apache/camel/pull/24901#issuecomment-5023825175
Applied all review fixes from @oscerd on [PR #24901](https://github.com/apache/camel/pull/24901) for **CAMEL-23394**. Summary: ## Blocking fix — immutable list `OpenAIConversationHistoryTrimmer.trim()` no longer returns `List.of()`. It now returns mutable `ArrayList` instances so `OpenAIProducer` / `OpenAIToolExecutionProducer` can safely call `history.add(...)` on later route hops without `UnsupportedOperationException`. ## Other review items addressed | Item | Fix | |------|-----| | Token-limit asymmetry | `findFirstSegmentForTokenLimit` always keeps the last segment (matches message-limit semantics) + **WARN** when that segment alone exceeds the budget | | Dead code | Removed the inner `List.of()` safety check (lines 75–77) | | `int` overflow | Char accumulator uses `long` with clamp to `Integer.MAX_VALUE` | | Route test for `maxHistoryTokens` | Added `OpenAIConversationHistoryTokenLimitTest` (4-turn mock route) | | Mutable list unit tests | Added 3 tests in `OpenAIConversationHistoryTrimmerTest` | | Docs | Updated `openai-component.adoc` Conversation Memory section | | Metadata | Updated `@Metadata` on `maxHistoryTokens` + regenerated `openai.json` / catalog JSON | ## Test results Full `camel-openai` unit suite in `C:\c\camel-23394-fix`: ``` Tests run: 115, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS ``` New/updated history tests: **13 total** (was 9 before). ## Files changed - `OpenAIConversationHistoryTrimmer.java` — core fixes - `OpenAIConfiguration.java` — metadata update - `OpenAIConversationHistoryTrimmerTest.java` — 3 new unit tests - `OpenAIConversationHistoryTokenLimitTest.java` — new route-level test - `openai-component.adoc` — docs - `openai.json` + catalog `openai.json` — generated metadata -- 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]
