优化: agentic防护与删除审批子代理域
- 循环主体 catch_unwind 防护,panic 走正典终态不再卡死 - 会话删除停 in-flight 循环+删除侧单点补发终态 - 审批超时到点主动收敛,执行等待循环加删除判死 - 子代理出口整轨迹落库,拒绝工具结构化+报告协议 - 压缩会话 id 修正,begin_turn 喂用户原文 - 远程桥会话列表按 origin 过滤子会话,新增中断续跑命令
This commit is contained in:
@@ -181,6 +181,10 @@ pub enum AiChatEvent {
|
||||
is_estimated: bool,
|
||||
/// 不完整标记(可选):Some(true)=网络中断保文,None 或 Some(false)=完整回复
|
||||
incomplete: Option<bool>,
|
||||
/// 不完整原因(与 incomplete 配合):Some("max_rounds")=达最大轮次自动收尾,
|
||||
/// Some("network")=流中途网络中断保文,None=完整回复/未分类。前端据此选文案:
|
||||
/// "max_rounds" → 「已达最大轮次自动收尾」,其他/缺省 → 网络中断文案。
|
||||
incomplete_reason: Option<String>,
|
||||
conversation_id: Option<String>,
|
||||
/// 当前会话 pinned_goals(G1 目标钉扎持久化,前端直接读取刷新)
|
||||
pinned_goals: Vec<GoalEntry>,
|
||||
@@ -231,6 +235,7 @@ pub enum AiChatEvent {
|
||||
/// - `conversation_id`:父会话 id(路由键,挂父不挂子,子会话不在侧栏)
|
||||
/// - `status`:"completed" | "truncated" | "failed"
|
||||
/// - `rounds`/`tokens`:实际执行轮数与累计 token(启动失败为 0)
|
||||
/// - `rejected_tools`:被拒工具清单("工具名×次数",如 "write_file×3"),None=本次零拒绝
|
||||
AiAgentFinished {
|
||||
agent_id: String,
|
||||
conversation_id: Option<String>,
|
||||
@@ -238,6 +243,9 @@ pub enum AiChatEvent {
|
||||
status: String,
|
||||
rounds: u32,
|
||||
tokens: u64,
|
||||
/// S2 报告协议:子循环运行期被拒工具汇总,让父会话与用户看见子代理被拒了什么。
|
||||
/// 可选字段:前端 S1 完成卡不消费该字段也不破坏(事件多字段向后兼容),消费留二期。
|
||||
rejected_tools: Option<Vec<String>>,
|
||||
},
|
||||
/// 流式调用自动重试提示流前失败重试中)
|
||||
///
|
||||
@@ -643,6 +651,10 @@ pub struct AiSession {
|
||||
/// 删除语义:删了就删了,loop 后续 save 不应复活。conv_id 是 ULID 不重用,条目长期保留
|
||||
/// (单条 ~40B,删除量级下可忽略)。
|
||||
pub deleted_convs: HashSet<String>,
|
||||
/// 会话来源标记(V44 子轨迹落库):conv_id → origin(现仅 "sub_agent")。
|
||||
/// save 首插时随 record 落 origin 列,桌面侧栏/miniapp 列表按此过滤子会话。
|
||||
/// 子代理启动时写入,出口清理时随 per_conv 一并移除;主会话无条目(None)。
|
||||
pub conv_origins: HashMap<String, String>,
|
||||
/// 每会话 save 串行锁:同会话并发 save(loop 与 IPC)串行化,防全量重写互踩吞新行
|
||||
pub save_locks: HashMap<String, Arc<tokio::sync::Mutex<()>>>,
|
||||
/// T2 工具命名空间存储(运行时缓存,大工具结果不进主队列)
|
||||
@@ -658,6 +670,7 @@ impl AiSession {
|
||||
pending_approvals: HashMap::new(),
|
||||
per_conv: HashMap::new(),
|
||||
deleted_convs: HashSet::new(),
|
||||
conv_origins: HashMap::new(),
|
||||
save_locks: HashMap::new(),
|
||||
namespace_store: df_ai::namespace_store::NamespaceStore::default(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user