修复: spawn panic 兜底 + namespace 淘汰提示 + run_command 超时与破坏命令信任门控
This commit is contained in:
@@ -120,8 +120,9 @@ pub(super) async fn maybe_auto_compress(
|
||||
|
||||
// T2-修复(方案A):展开 namespace 引用为真实内容,再喂压缩 LLM/关键词摘要。
|
||||
// 同 agentic/mod.rs 的 build_for_request 出口展开。未展开则压缩 LLM 只看到
|
||||
// "namespace://..." 占位符,摘要基于占位符丢主题。read_only None(重启后 namespace
|
||||
// 清空/残留引用)→ 保留占位符降级,非崩溃。
|
||||
// "namespace://..." 占位符,摘要基于占位符丢主题。read_only None(条目被 LRU 淘汰 /
|
||||
// 重启后 namespace 清空 / 跨会话残留引用)→ 替换为 EVICTED_PLACEHOLDER 提示文案
|
||||
// (非保留无意义 namespace:// URI)+ warn 日志。
|
||||
{
|
||||
let session = session_arc.lock().await;
|
||||
for m in &mut active_msgs {
|
||||
@@ -129,6 +130,13 @@ pub(super) async fn maybe_auto_compress(
|
||||
let path = m.content.clone();
|
||||
if let Some(original) = session.namespace_store.read_only(&path) {
|
||||
m.content = original.to_string();
|
||||
} else {
|
||||
tracing::warn!(
|
||||
conv_id = %conv_id,
|
||||
path = %path,
|
||||
"[namespace] 引用已淘汰,替换为提示文案"
|
||||
);
|
||||
m.content = df_ai::namespace_store::EVICTED_PLACEHOLDER.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +809,13 @@ pub(crate) async fn run_agentic_loop(
|
||||
// conv_id 来源:run_agentic_loop 入参(loop 启动快照,与 guard 一致)。
|
||||
let (stop_flag, notify) = {
|
||||
let session = session_arc.lock().await;
|
||||
let conv = session.conv_read(&conv_id).expect("[F-09] loop 入口桥接后 per_conv 必存在");
|
||||
// panic-guard:原裸 .expect 在 conv 已删(并发删除/状态竞态)时 panic,
|
||||
// guard 不 reset/终态不发/registry 不清致永久卡。改为 None 显式退出(对齐同函数其他 return 点;
|
||||
// guard Drop 兜底复位 generating)。
|
||||
let Some(conv) = session.conv_read(&conv_id) else {
|
||||
tracing::warn!(stale_conv = %conv_id, "[ai] loop 入口 conv 已删,退出");
|
||||
return;
|
||||
};
|
||||
(conv.stop_flag.clone(), conv.notify.clone())
|
||||
};
|
||||
|
||||
@@ -1215,12 +1221,20 @@ pub(crate) async fn run_agentic_loop(
|
||||
// namespace_store 引用化进 messages;持久化(conversation.rs)已展开写 DB,但发 LLM 的
|
||||
// 实时请求此前未展开 → LLM 每轮只看到 "namespace://..." 占位符,AI 实际拿不到工具结果。
|
||||
// 此处展开,namespace 退化为内存/持久化层优化,LLM 永远看真实内容。
|
||||
// read_only None(重启后 namespace 清空 / 跨会话残留引用)→ 保留占位符降级,非崩溃。
|
||||
// read_only None(条目被 LRU 淘汰 / 重启后 namespace 清空 / 跨会话残留引用)→
|
||||
// 替换为 EVICTED_PLACEHOLDER 提示文案(非保留无意义 namespace:// URI)+ warn 日志。
|
||||
for m in &mut history_msgs {
|
||||
if df_ai::namespace_store::is_namespace_ref(&m.content) {
|
||||
let path = m.content.clone();
|
||||
if let Some(original) = session.namespace_store.read_only(&path) {
|
||||
m.content = original.to_string();
|
||||
} else {
|
||||
tracing::warn!(
|
||||
conv_id = %conv_id,
|
||||
path = %path,
|
||||
"[namespace] 引用已淘汰,替换为提示文案"
|
||||
);
|
||||
m.content = df_ai::namespace_store::EVICTED_PLACEHOLDER.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user