fix: CompactionHook token over-count when no assistant message is present - #12581
fix: CompactionHook token over-count when no assistant message is present#12581RahilOp wants to merge 1 commit into
Conversation
…sent Signed-off-by: Syed Ali Abbas Rahil <viperboom0786110@gmail.com>
|
@RahilOp is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
|
|
Hi @RahilOp, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
Fixes #12580\n\nWhen
context_tokens > 0but the conversation has no assistant message,_estimated_context_tokenswas counting the entire message list on top of the provider's reported usage. This change short-circuits and returnscontext_tokenswhen there is no assistant message, matching the behavior described in the issue.\n\nChanges:\n- Updated_estimated_context_tokensinhaystack/hooks/compaction/utils.py.\n- Added regression tests intest/hooks/compaction/test_utils.py.\n- Added release note.