fix(chat-state): reasoning estimate and calibration reseed on every rewrite
A Reasoning item counted its text and its encrypted blob as two separate payloads, inflating the estimate for retained reasoning; the estimate now takes the larger of the two (base64 runs 4/3 over the raw bytes). Only compaction carried the provider-confirmed ratio into the reseeded total; a rewind or a non-compaction replace sprang the context meter back to the raw estimate. reseed_total_tokens applies the ratio (capped at the pre-rewrite total) to every rewrite, and the truncate path uses it too. Ported from upstream 1.0.1x (grok-build xai-chat-state actor/state.rs, mutations.rs, queries.rs). Claude-Session: https://claude.ai/code/session_01RUqV8HVGXcAETyYbZ2tPQ4
This commit is contained in:
1 parent
00a5e318bb
commit
fc7113ba3c
4 files changed
+73
-33
No files matched your search
@@ -68,10 +68,10 @@ impl ChatStateActor {
|
||||
self.state.conversation.truncate(truncate_at);
|
||||
self.state.prompt_texts.truncate(target_prompt_index);
|
||||
self.state.prompt_index = target_prompt_index;
|
||||
self.state.total_tokens =
|
||||
super::state::estimate_conversation_tokens(&self.state.conversation);
|
||||
let base_estimate = super::state::estimate_conversation_tokens(&self.state.conversation);
|
||||
self.state.total_tokens = self.reseed_total_tokens(base_estimate);
|
||||
self.state.estimated_tokens_since_model = 0;
|
||||
self.state.estimate_at_last_response = self.state.total_tokens;
|
||||
self.state.estimate_at_last_response = base_estimate;
|
||||
|
||||
self.persistence.replace_history(&self.state.conversation);
|
||||
|
||||
|
||||
Reference in new issue
Block a user