Refactor tool execution pipeline
This commit is contained in:
+10
-5
@@ -131,7 +131,11 @@ impl ApprovalManager {
|
||||
|
||||
/// 处理用户回复(由消息循环调用)
|
||||
/// 返回 (技能名, 决策);匹配失败返回 None
|
||||
pub async fn handle_reply(&self, user_id: &str, reply: &str) -> Option<(String, ApprovalDecision)> {
|
||||
pub async fn handle_reply(
|
||||
&self,
|
||||
user_id: &str,
|
||||
reply: &str,
|
||||
) -> Option<(String, ApprovalDecision)> {
|
||||
let (result, name, code_hash) = {
|
||||
let mut map = self.pending.lock().await;
|
||||
let entries = map.get_mut(user_id)?;
|
||||
@@ -216,10 +220,11 @@ impl ApprovalManager {
|
||||
let mut map = self.pending.lock().await;
|
||||
for (uid, i, _) in expired.iter().rev() {
|
||||
if let Some(entries) = map.get_mut(uid)
|
||||
&& *i < entries.len() {
|
||||
let entry = entries.remove(*i);
|
||||
let _ = entry.sender.send(ApprovalDecision::Expired);
|
||||
}
|
||||
&& *i < entries.len()
|
||||
{
|
||||
let entry = entries.remove(*i);
|
||||
let _ = entry.sender.send(ApprovalDecision::Expired);
|
||||
}
|
||||
}
|
||||
map.retain(|_, v| !v.is_empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user