atiaomar1978-hub commented on PR #24901:
URL: https://github.com/apache/camel/pull/24901#issuecomment-5013401730

   All three review points are addressed in commit `84b52e74442` (pushed).
   
   ### 1. Tool-call / tool-result pairing
   Trimmer now works on **segments**:
   - Assistant message with `tool_calls` + following `tool` messages = one 
atomic segment
   - Oldest **segments** are dropped, never a lone `tool` message without its 
assistant block
   - If keeping the latest N messages would orphan a tool result, the whole 
tool block is dropped instead (keeps only the trailing assistant reply)
   
   **New tests:** 
`trimShouldKeepAssistantToolCallBlockIntactWhenMessageLimitWouldSplitIt`, 
`trimShouldRetainAssistantAndToolResultsAsOneSegment`
   
   ### 2. O(n²) `remove(0)` loop
   Token trimming now advances a **segment index** and uses `subList` once — 
O(segments), not repeated `remove(0)`.
   
   ### 3. Image token estimate
   Multi-modal user messages now count **image URL/base64 payload length** 
(plus text parts) in the chars÷4 heuristic.
   
   **New test:** `estimateTokensShouldIncludeImagePayloadSize`
   
   ### Docs
   `@Metadata` / `openai.json` updated to describe segment-based trimming and 
image payload estimation.
   
   **Tests:** 103/103 passed


-- 
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]

Reply via email to