mirror of
https://github.com/openai/codex.git
synced 2026-05-05 05:42:33 +03:00
Stop client from being state carrier (#10595)
I'd like to make client session wide. This requires shedding all random state it has to carry.
This commit is contained in:
@@ -85,10 +85,8 @@ impl ContextManager {
|
||||
// Estimate token usage using byte-based heuristics from the truncation helpers.
|
||||
// This is a coarse lower bound, not a tokenizer-accurate count.
|
||||
pub(crate) fn estimate_token_count(&self, turn_context: &TurnContext) -> Option<i64> {
|
||||
let model_info = turn_context.client.get_model_info();
|
||||
let personality = turn_context
|
||||
.personality
|
||||
.or(turn_context.client.config().personality);
|
||||
let model_info = &turn_context.model_info;
|
||||
let personality = turn_context.personality.or(turn_context.config.personality);
|
||||
let base_instructions = model_info.get_model_instructions(personality);
|
||||
let base_tokens = i64::try_from(approx_token_count(&base_instructions)).unwrap_or(i64::MAX);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user