feat: prompt_cache skip compress + style

This commit is contained in:
Liang Jiaqing
2026-03-20 23:47:15 +08:00
parent 05800a4f48
commit 85f17db487
2 changed files with 4 additions and 4 deletions

View File

@@ -79,8 +79,7 @@ def agent_runner_loop(client, system_prompt, user_input, handler, tools_schema,
yield '`````\n'
outcome = yield from gen
yield '`````\n'
else:
outcome = exhaust(gen)
else: outcome = exhaust(gen)
if outcome.next_prompt is None: return {'result': 'CURRENT_TASK_DONE', 'data': outcome.data}
if outcome.should_exit: return {'result': 'EXITED', 'data': outcome.data}

View File

@@ -73,8 +73,9 @@ class ClaudeSession:
self.default_model = cfg.get('model', 'claude-opus')
self.context_win = cfg.get('context_win', 12000)
self.raw_msgs, self.lock = [], threading.Lock()
self.prompt_cache = cfg.get('prompt_cache', False)
def _trim_messages(self, messages):
compress_history_tags(messages)
if not self.prompt_cache: compress_history_tags(messages)
total = sum(len(m['prompt']) for m in messages)
if total <= self.context_win * 4: return messages
target, current, result = self.context_win * 4 * 0.9, 0, []
@@ -270,7 +271,7 @@ class LLMSession:
return
def make_messages(self, raw_list, omit_images=True):
compress_history_tags(raw_list)
if not self.prompt_cache: compress_history_tags(raw_list)
messages = []
for i, msg in enumerate(raw_list):
prompt = msg['prompt']