feat(bot): Bot session compact by using openviking, ov client add function and param#2284
Conversation
PR Reviewer Guide 🔍(Review updated until commit 21fda3b)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
Persistent review updated to latest commit 21fda3b |
PR Code Suggestions ✨No code suggestions found for the PR. |
qin-ctx
left a comment
There was a problem hiding this comment.
本次 review 发现 2 个 blocking 问题,已 inline 标注:batch add 没有处理服务端 100 条上限,以及 session-context 主链路会把完整 tool result 写入长上下文。另有一个非阻塞行为风险已 inline 标注。\n\n额外的非阻塞建议:这个 PR 目前包含两个 merge commit 和多个 fix bug / 默认值 commit,PR body 的 Type/Testing checklist 也还没有补完整;建议 merge 前 squash 并补齐测试说明。
qin-ctx
left a comment
There was a problem hiding this comment.
这轮复查确认之前 3 个问题都已经修复:batch add 已按 100 条分片、session-context 不再写入完整 tool result、pre-turn commit 已移到 outcome evaluation 之后。
但还有一个需要阻塞合并的问题:commit 后清空本地 messages 时,last_sender_synced_local_indexes 可能因为 session metadata 的递归 merge 被旧值合回来,导致后续 per-user fanout 漏同步同一 sender 的新消息。这个会影响 user-scoped memory/context 的完整性,建议修复后再合并。
额外建议:session_context_token_budget 目前只约束 OV context,最终 prompt 仍可能因为 local unsynced tail 过长而超窗;PR body 的 Type/Testing checklist 和 commit history 也建议合并前整理。
Description
Summary
本次改造将 VikingBot 的长对话压缩链路接入 OpenViking session context,把原来的本地 JSONL compact 流程替换为“本地短期原始日志 + OpenViking 长上下文压缩层”的双层结构。
核心变化:
新增基于稳定 OpenViking session 的上下文压缩模式:
get_session_context()读取 OV 摘要和 live messages;保持 OpenViking 写入和 commit 逻辑收敛在
openviking_hooks.py:sender_idfanout 到<session_id>_<sender_id>;memory_window双条件触发 commit。新增 session-context 相关配置到
AgentsConfig:session_context_enabledsession_context_token_budgetcommit_token_thresholdcommit_keep_recent_count扩展 OpenViking client/session wrapper:
batch_add_messages(...);commit_session(..., keep_recent_count=...);commit 成功后清理本地 JSONL session:
增强同步状态一致性:
session_state.py管理 OV metadata / cursor / unsynced tail;Related Issue
Type of Change
Changes Made
Testing
Checklist
Screenshots (if applicable)
Additional Notes