diff --git a/assets/configure_mykey.py b/assets/configure_mykey.py index b9ed19d7e..de685e6cc 100644 --- a/assets/configure_mykey.py +++ b/assets/configure_mykey.py @@ -90,6 +90,7 @@ 'name': 'deepseek', 'apikey': 'sk-', 'apibase': 'https://api.deepseek.com', 'model': 'deepseek-v4-pro', 'api_mode': 'chat_completions', 'reasoning_effort': 'high', + 'context_win': 1000000, 'max_tokens': 384000, }, 'key_hint': '在 https://platform.deepseek.com/api_keys 获取', 'model_choices': ['deepseek-v4-pro', 'deepseek-v4-flash'], @@ -266,6 +267,7 @@ 'apibase': 'https://api.xiaomimimo.com/v1', 'model': 'mimo-v2.5-pro', 'api_mode': 'chat_completions', + 'context_win': 1000000, 'max_tokens': 128000, }, 'key_hint': '在 https://x.xiaomi.com/ 获取 API Key', 'model_choices': ['mimo-v2.5-pro', 'mimo-v2-flash'], diff --git a/frontends/cost_tracker.py b/frontends/cost_tracker.py index 744258982..d322f6533 100644 --- a/frontends/cost_tracker.py +++ b/frontends/cost_tracker.py @@ -39,15 +39,15 @@ def elapsed_seconds(self) -> float: return max(0.0, time.time() - self.started_at) -# GA's real context budget lives on `BaseSession.context_win` (chars). The -# trim trigger is `context_win * 3` (see llmcore.trim_messages_history), so -# `/cost` compares actual-history chars against that cap for consistent units. +# GA's real context budget lives on `BaseSession.context_win` (chars). +# `/cost` displays this value directly so users see the actual context window. def context_window_chars(backend) -> int: - """`context_win * 3` — the char cap before `trim_messages_history` kicks - in. Reads dynamically so a `mykey.py` override propagates. Returns 0 on - bad/missing backend so the caller can hide the row.""" + """Returns the actual context_win (no multiplier). The internal trim + trigger is `context_win * 3` (see llmcore.trim_messages_history), but the + display should show the real model capacity. Returns 0 on bad/missing + backend so the caller can hide the row.""" try: - return int(getattr(backend, 'context_win', 0)) * 3 + return int(getattr(backend, 'context_win', 0)) except (TypeError, ValueError): return 0 diff --git a/frontends/tui_v3.py b/frontends/tui_v3.py index 0684d538d..f046dc349 100644 --- a/frontends/tui_v3.py +++ b/frontends/tui_v3.py @@ -2333,7 +2333,7 @@ def _indent_rows(rows: list[str], width: int) -> list[str]: def _cost_str(agent) -> str: - """Context-window usage view (cc/v2 style): used / cap of context_win*3.""" + """Context-window usage view (cc/v2 style): used / cap of context_win.""" try: from frontends import cost_tracker be = agent.llmclient.backend @@ -4478,8 +4478,8 @@ def _cmd(self, raw: str) -> None: try: from frontends import cost_tracker as _ct cap = _ct.context_window_chars(be) if be is not None else 0 - used = _ct.context_chars_used(be) if be is not None else 0 - ctx_use = _t('status.ctx.fmt', used=used, cap=cap * 3) if cap else _t('status.ctx.unknown') + used = _ct.current_input_chars(be) if be is not None else 0 + ctx_use = _t('status.ctx.fmt', used=used, cap=cap) if cap else _t('status.ctx.unknown') except Exception: ctx_use = _t('status.ctx.unknown') cwd = os.getcwd().replace(os.path.expanduser('~'), '~') diff --git a/llmcore.py b/llmcore.py index cc9f34a7f..f0f317a60 100644 --- a/llmcore.py +++ b/llmcore.py @@ -530,7 +530,7 @@ def __init__(self, cfg): self.model = cfg.get('model', '') default_context_win = 30000 if 'deepseek' in self.model.lower(): - default_context_win = 70000; self.cut_msg_interval = 25; self.trim_keep_rate = 0.3 + default_context_win = 1000000; self.cut_msg_interval = 25; self.trim_keep_rate = 0.3 self.context_win = cfg.get('context_win', default_context_win) self.history = []; self.lock = threading.Lock(); self.system = "" self.name = cfg.get('name', self.model)