mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
fix: a chat compacted on demand is compacted again although little is left (#35679)
Compacting a chat by hand stores the summary on the last reply, and that reply still carried the token count of the whole history the summary replaced. The server kept counting the chat at its size from before the compaction, so when later replies reported no token count, a short chat was compacted again a couple of messages later and its reported context usage stayed at the old size. The server now counts from what is actually left after the compaction. The context usage shown in the chat (/status) is worked out by the page itself and gets the matching change in a separate fix. Related to #35678
This commit is contained in:
1 parent
26dd07f01b
commit
22f8516dd9
1 file changed
+2
@@ -318,6 +318,8 @@ def _apply_latest_summary_checkpoint(messages: list[dict]) -> tuple[list[dict],
|
||||
[{**message, 'contextSummary': None, 'context_summary': None}]
|
||||
)
|
||||
message = {**message, 'output': trimmed_message['output']}
|
||||
# A reply compacted on demand still carries the usage of the history its summary replaced.
|
||||
message = {key: item for key, item in message.items() if key != 'usage'}
|
||||
return [message, *messages[idx + 1 :]], value
|
||||
|
||||
marker = next(
|
||||
|
||||
Reference in new issue
Block a user