INNER CODE UNIT · Python

last_user_i

usepr/eva · eva.py:393

    last_user_i = compact_i - 1
    for i in range(last_user_i, -1, -1):
        if messages[i]['role'] == 'user':
            last_user_i = i
            break

    # 对保留片段中的 tool result 做截断,避免压缩后体积依然过大
    kept = []
    for m in messages[last_user_i:compact_i]:
        kept.append(_trim_tool_content(m))
    if len(kept) > 200: # 最多保留200条消息
        kept = kept[:100] + kept[-100:]

    # 先持久化,再同步进当前进程;写入失败时不应清空消息历史
    with open(HINT_FILE, "w", encoding="utf-8") as f:
        f.write(hints)

    memory_hints = hints

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…