Fix Rig tool continuation and plan creation
This commit is contained in:
@@ -188,6 +188,7 @@ pub fn recall_tool_history(
|
||||
|
||||
let filtered = entries
|
||||
.iter()
|
||||
.filter(|entry| entry.name != RECALL_TOOL_HISTORY_NAME)
|
||||
.filter(|entry| {
|
||||
(query.tool_use_id.is_empty() || entry.tool_use_id == query.tool_use_id)
|
||||
&& (query.tool_name.is_empty() || entry.name == query.tool_name)
|
||||
|
||||
@@ -141,6 +141,21 @@ fn recall_supports_exact_call_id_and_case_insensitive_text_search() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recall_never_returns_a_prior_recall_call() {
|
||||
let messages = tool_exchange(
|
||||
"recall-1",
|
||||
RECALL_TOOL_HISTORY_NAME,
|
||||
serde_json::json!({}),
|
||||
"a prior synthetic recall result",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
recall_tool_history(&messages, &[], ToolHistoryQuery::default()),
|
||||
"No matching tool calls found in conversation history."
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loop_guard_detects_repeated_failures_and_resets_after_detection() {
|
||||
let mut guard = ToolLoopGuard::new(5, 3);
|
||||
|
||||
@@ -226,16 +226,28 @@ fn request_conversion_preserves_history_tools_and_limits() {
|
||||
request.system_prompt = Some("Be useful".to_string());
|
||||
request.max_output_tokens = Some(123);
|
||||
request.tools.push(galaxy_agent_core::ToolDefinition {
|
||||
name: "shell".to_string(),
|
||||
description: "Run a command".to_string(),
|
||||
input_schema: serde_json::json!({"type": "object"}),
|
||||
name: "create_plan".to_string(),
|
||||
description: "Create a plan document".to_string(),
|
||||
input_schema: serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {"documents": {"type": "array"}},
|
||||
"required": ["documents"]
|
||||
}),
|
||||
});
|
||||
|
||||
let converted = build_completion_request(request, Some(999), true).unwrap();
|
||||
|
||||
assert_eq!(converted.max_tokens, Some(123));
|
||||
assert_eq!(converted.tools.len(), 1);
|
||||
assert_eq!(converted.tools[0].name, "shell");
|
||||
assert_eq!(converted.tools[0].name, "create_plan");
|
||||
assert_eq!(
|
||||
converted.tools[0].parameters,
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {"documents": {"type": "array"}},
|
||||
"required": ["documents"]
|
||||
})
|
||||
);
|
||||
assert_eq!(converted.chat_history.len(), 2);
|
||||
assert!(matches!(
|
||||
converted.chat_history.iter().next(),
|
||||
|
||||
Reference in New Issue
Block a user