From 3dacf6ff1fdb67ca77549d076bd2cf515500ec1f Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 16 Apr 2025 09:29:24 -0600 Subject: [PATCH] low reasoning with conditions --- api/libs/agents/src/agent.rs | 2 +- .../agents/src/agents/buster_multi_agent.rs | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/api/libs/agents/src/agent.rs b/api/libs/agents/src/agent.rs index 23b018c4f..792897708 100644 --- a/api/libs/agents/src/agent.rs +++ b/api/libs/agents/src/agent.rs @@ -618,7 +618,7 @@ impl Agent { session_id: thread.id.to_string(), trace_id: Uuid::new_v4().to_string(), }), - reasoning_effort: Some("medium".to_string()), + reasoning_effort: Some("low".to_string()), ..Default::default() }; diff --git a/api/libs/agents/src/agents/buster_multi_agent.rs b/api/libs/agents/src/agents/buster_multi_agent.rs index 6b66e9972..e8a67e852 100644 --- a/api/libs/agents/src/agents/buster_multi_agent.rs +++ b/api/libs/agents/src/agents/buster_multi_agent.rs @@ -139,6 +139,28 @@ impl BusterMultiAgent { && state.contains_key("data_context") }); + // Define the new condition for the Done tool + let done_condition = Some(|state: &HashMap| -> bool { + let review_needed = state.get("review_needed") + .and_then(Value::as_bool) + .unwrap_or(false); + + // Check if all todos are marked as complete + // Assumes 'todos' is an array of objects, each with a 'completed' boolean field + let all_todos_complete = state.get("todos") + .and_then(Value::as_array) + .map(|todos| { + todos.iter().all(|todo| { + todo.get("completed") + .and_then(Value::as_bool) + .unwrap_or(false) // Treat missing 'completed' as false + }) + }) + .unwrap_or(false); // If 'todos' doesn't exist or isn't an array, assume not all complete + + review_needed || all_todos_complete + }); + // Add tools to the agent with their conditions self.agent .add_tool( @@ -207,7 +229,7 @@ impl BusterMultiAgent { .add_tool( done_tool.get_name(), done_tool.into_tool_call_executor(), - after_search_condition.clone(), // Use after_search_condition instead of None + done_condition, // Use the new done_condition ) .await; self.agent