不管前缀,管子代理的 KV 缓存亲和性
四家里唯一不在「前缀复用」这一层解决问题的。它的 kv_cache 模块处理的是路由亲和:特定类型的子代理(browser_agent、verification_agent)被标为 sticky,配合 prefetch / finish / evict 三个生命周期钩子,让同一个子会话尽量落到同一个推理后端上,从而复用已有的 KV 缓存。子会话 id 由「父会话 id + 任务 id」推导,保证跨轮次稳定。这是把缓存当作调度问题而不是拼装问题。
def affinity_enabled(deep_agent: Any) -> bool:
"""Return without inspecting model/binding state when affinity is disabled."""
deep_config = getattr(deep_agent, "deep_config", None)
kv_config = getattr(deep_config, "kv_cache_affinity_config", None)
return getattr(kv_config, "enable_kv_cache_affinity", False) is True
def is_sticky_subagent_type(subagent_type: str) -> bool:
return str(subagent_type or "").strip() in ("browser_agent", "verification_agent")
# 同文件另有 prefetch_sticky_subagent / finish_subagent / evict_subagent
# 三个生命周期钩子(44-128 行),以及由父会话 id + task_id 推导的稳定子会话 id。