first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,7 +1,56 @@
|
||||
use crate::ai::agent::api::convert_conversation::*;
|
||||
use crate::ai::agent::{AIAgentInput, UserQueryMode};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use chrono::Utc;
|
||||
use warp_multi_agent_api as api;
|
||||
|
||||
use crate::ai::agent::api::convert_conversation::*;
|
||||
use crate::ai::agent::api::ServerConversationToken;
|
||||
use crate::ai::agent::conversation::{
|
||||
AIAgentHarness, AIConversationId, ServerAIConversationMetadata,
|
||||
};
|
||||
use crate::ai::agent::{AIAgentInput, UserQueryMode};
|
||||
use crate::ai::ambient_agents::AmbientAgentTaskId;
|
||||
use crate::cloud_object::{Revision, ServerMetadata, ServerPermissions};
|
||||
use crate::persistence::model::ConversationUsageMetadata;
|
||||
use crate::server::ids::ServerId;
|
||||
|
||||
fn test_server_metadata(
|
||||
server_token: &str,
|
||||
ambient_agent_task_id: Option<AmbientAgentTaskId>,
|
||||
) -> ServerAIConversationMetadata {
|
||||
ServerAIConversationMetadata {
|
||||
title: "test conversation".to_string(),
|
||||
working_directory: None,
|
||||
harness: AIAgentHarness::Oz,
|
||||
usage: ConversationUsageMetadata {
|
||||
was_summarized: false,
|
||||
context_window_usage: 0.0,
|
||||
credits_spent: 0.0,
|
||||
platform_credits_spent: 0.0,
|
||||
credits_spent_for_last_block: None,
|
||||
token_usage: vec![],
|
||||
tool_usage_metadata: Default::default(),
|
||||
context_window_segments: Vec::new(),
|
||||
},
|
||||
metadata: ServerMetadata {
|
||||
uid: ServerId::default(),
|
||||
revision: Revision::now(),
|
||||
metadata_last_updated_ts: Utc::now().into(),
|
||||
trashed_ts: None,
|
||||
folder_id: None,
|
||||
is_welcome_object: false,
|
||||
creator_uid: None,
|
||||
last_editor_uid: None,
|
||||
current_editor_uid: None,
|
||||
},
|
||||
permissions: ServerPermissions::mock_personal(),
|
||||
creator: None,
|
||||
ambient_agent_task_id,
|
||||
server_conversation_token: ServerConversationToken::new(server_token.to_string()),
|
||||
artifacts: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn test_skill() -> api::Skill {
|
||||
api::Skill {
|
||||
descriptor: Some(api::SkillDescriptor {
|
||||
@@ -25,6 +74,40 @@ fn test_skill() -> api::Skill {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_convert_conversation_data_to_ai_conversation_sets_restored_run_id() {
|
||||
let conversation_id = AIConversationId::new();
|
||||
let ambient_agent_task_id: AmbientAgentTaskId =
|
||||
"550e8400-e29b-41d4-a716-446655440000".parse().unwrap();
|
||||
let conversation_data = api::ConversationData {
|
||||
tasks: vec![api::Task {
|
||||
id: "root".to_string(),
|
||||
messages: vec![],
|
||||
dependencies: None,
|
||||
description: String::new(),
|
||||
summary: String::new(),
|
||||
server_data: String::new(),
|
||||
}],
|
||||
ordered_message_ids: vec![],
|
||||
};
|
||||
|
||||
let conversation = convert_conversation_data_to_ai_conversation(
|
||||
conversation_id,
|
||||
&conversation_data,
|
||||
test_server_metadata("server-token", Some(ambient_agent_task_id)),
|
||||
RestorationMode::Continue,
|
||||
)
|
||||
.expect("conversation should restore");
|
||||
|
||||
assert_eq!(conversation.id(), conversation_id);
|
||||
assert_eq!(conversation.task_id(), Some(ambient_agent_task_id));
|
||||
assert_eq!(
|
||||
conversation.run_id(),
|
||||
Some(ambient_agent_task_id.to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_convert_tool_call_result_to_input_transfer_control_snapshot() {
|
||||
let task_id = crate::ai::agent::task::TaskId::new("task".to_string());
|
||||
@@ -277,6 +360,7 @@ fn test_into_exchanges_basic() {
|
||||
// Create minimal test data
|
||||
let messages = vec![
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -292,6 +376,7 @@ fn test_into_exchanges_basic() {
|
||||
timestamp: None,
|
||||
},
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -305,6 +390,7 @@ fn test_into_exchanges_basic() {
|
||||
timestamp: None,
|
||||
},
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -320,6 +406,7 @@ fn test_into_exchanges_basic() {
|
||||
timestamp: None,
|
||||
},
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_msg2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -333,6 +420,7 @@ fn test_into_exchanges_basic() {
|
||||
timestamp: None,
|
||||
},
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg3".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -348,6 +436,7 @@ fn test_into_exchanges_basic() {
|
||||
timestamp: None,
|
||||
},
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_msg3".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -392,6 +481,7 @@ fn test_invoke_skill_arguments_round_trip() {
|
||||
let query = "arg1 arg2".to_string();
|
||||
let messages = vec![
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "invoke_skill_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -412,6 +502,7 @@ fn test_invoke_skill_arguments_round_trip() {
|
||||
timestamp: None,
|
||||
},
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -448,7 +539,7 @@ fn test_invoke_skill_arguments_round_trip() {
|
||||
Some("arg1 arg2")
|
||||
);
|
||||
assert_eq!(
|
||||
exchanges[0].input[0].user_query().as_deref(),
|
||||
exchanges[0].input[0].display_query().as_deref(),
|
||||
Some("/test-skill arg1 arg2")
|
||||
);
|
||||
}
|
||||
@@ -459,6 +550,7 @@ fn test_invoke_skill_arguments_round_trip() {
|
||||
#[test]
|
||||
fn test_invoke_skill_missing_user_query_maps_to_none() {
|
||||
let messages = vec![api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "invoke_skill_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -492,7 +584,7 @@ fn test_invoke_skill_missing_user_query_maps_to_none() {
|
||||
assert_eq!(skill.name, "test-skill");
|
||||
assert_eq!(user_query, &None);
|
||||
assert_eq!(
|
||||
exchanges[0].input[0].user_query().as_deref(),
|
||||
exchanges[0].input[0].display_query().as_deref(),
|
||||
Some("/test-skill")
|
||||
);
|
||||
}
|
||||
@@ -505,6 +597,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
let messages = vec![
|
||||
// User query
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_query".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -521,6 +614,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Agent response
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_response".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -535,6 +629,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Tool call 1
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_1".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -558,6 +653,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Tool call 2
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -581,6 +677,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Tool call 3
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_3".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -604,6 +701,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Tool call result - cancelled (call_2)
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_cancelled".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -620,6 +718,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Tool call result - success (call_1)
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_success_1".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -639,6 +738,8 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
command_id: "command_1".to_string(),
|
||||
output: "1".to_string(),
|
||||
exit_code: 0,
|
||||
start_ts: None,
|
||||
finish_ts: None,
|
||||
},
|
||||
)),
|
||||
},
|
||||
@@ -650,6 +751,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Tool call result - success (call_3)
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_success_3".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -669,6 +771,8 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
command_id: "command_2".to_string(),
|
||||
output: "3".to_string(),
|
||||
exit_code: 0,
|
||||
start_ts: None,
|
||||
finish_ts: None,
|
||||
},
|
||||
)),
|
||||
},
|
||||
@@ -680,6 +784,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Final agent response
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "final_response".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -694,6 +799,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Follow-up user query
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "followup_query".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -710,6 +816,7 @@ fn test_into_exchanges_with_tool_calls_and_cancellation() {
|
||||
},
|
||||
// Final agent response
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "final_response2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -811,6 +918,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
let messages = vec![
|
||||
// User query asking for code changes
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_query".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -827,6 +935,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// Agent response
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_response".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -841,6 +950,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// File diff tool call
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "diff_call".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -862,6 +972,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// User cancels the diff
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "diff_cancelled".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -878,6 +989,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// User provides feedback
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_feedback".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -894,6 +1006,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// Agent response
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_response_2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -908,6 +1021,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// Second file diff tool call
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "diff_call_2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -929,6 +1043,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// User accepts the diff
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "diff_accepted".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -956,6 +1071,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// Final agent response
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "final_response".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -970,6 +1086,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// Follow-up user query
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "followup".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -986,6 +1103,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
},
|
||||
// Final agent response
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "final_response_2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1083,6 +1201,7 @@ fn test_into_exchanges_with_code_diffs() {
|
||||
fn test_user_query_mode_conversion() {
|
||||
// Test conversion with Plan mode
|
||||
let messages = vec![api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1129,6 +1248,7 @@ fn test_user_query_mode_conversion() {
|
||||
|
||||
// Test conversion with Normal mode (no type set)
|
||||
let messages_normal = vec![api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1173,6 +1293,7 @@ fn test_user_query_mode_conversion() {
|
||||
|
||||
// Test conversion with no mode field (should default to Normal)
|
||||
let messages_default = vec![api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1226,6 +1347,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
let messages = vec![
|
||||
// Message 0: Server message (should be ignored or handled gracefully)
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "2512077c-0ede-46b0-8f69-230c8792df07".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "78e236b8-84a2-45df-876e-ebfb86ceafc4".to_string(),
|
||||
@@ -1243,6 +1365,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 1: User query with request_id 78e236b8
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "4d6c450d-3d54-446f-974c-5c414e6083e9".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "78e236b8-84a2-45df-876e-ebfb86ceafc4".to_string(),
|
||||
@@ -1259,6 +1382,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 2: Agent output with same request_id
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "10210d1a-5298-45ef-90ba-df6367805080".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "78e236b8-84a2-45df-876e-ebfb86ceafc4".to_string(),
|
||||
@@ -1273,6 +1397,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 3: Tool call with same request_id
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "936c7c86-eb4a-4edf-97c0-22f5c61b35a6".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "78e236b8-84a2-45df-876e-ebfb86ceafc4".to_string(),
|
||||
@@ -1296,6 +1421,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 4: Tool call result with NEW request_id 59a3947f (starts new exchange)
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "cbebf5fb-4dd8-4aef-be45-bb916eff552c".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "59a3947f-fc7e-413a-96b5-baecd7e406dc".to_string(),
|
||||
@@ -1330,6 +1456,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 5: Agent output with same request_id
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "7a89857d-fa33-4d45-88e3-5fa9cbce3f20".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "59a3947f-fc7e-413a-96b5-baecd7e406dc".to_string(),
|
||||
@@ -1344,6 +1471,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 6: Write to long running command with NEW request_id 9f85acb2 (starts new exchange)
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "dac6d336-9fcb-4e34-bc2b-b06e70f52ec5".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "9f85acb2-0b1f-41b1-a0de-3623e131758a".to_string(),
|
||||
@@ -1374,6 +1502,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 7: Final tool call result with same request_id
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "ad319d66-fac0-4169-8bf1-e6004aca1619".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "9f85acb2-0b1f-41b1-a0de-3623e131758a".to_string(),
|
||||
@@ -1395,6 +1524,8 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
command_id: "cmd1".to_string(),
|
||||
output: "Done".to_string(),
|
||||
exit_code: 0,
|
||||
start_ts: None,
|
||||
finish_ts: None,
|
||||
},
|
||||
)),
|
||||
},
|
||||
@@ -1404,6 +1535,7 @@ fn test_exchanges_grouped_by_request_id() {
|
||||
},
|
||||
// Message 8: Final agent output with same request_id
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "f15f8a59-2e9c-416e-b216-83b3bd52d6be".to_string(),
|
||||
task_id: "d02463e1-2429-48de-ac8f-552df4acc4d0".to_string(),
|
||||
request_id: "9f85acb2-0b1f-41b1-a0de-3623e131758a".to_string(),
|
||||
@@ -1492,6 +1624,7 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
let messages = vec![
|
||||
// User query
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1508,6 +1641,7 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
},
|
||||
// Agent output
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_text".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1522,6 +1656,7 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
},
|
||||
// First CreateDocuments tool call
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_create_a".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1544,6 +1679,7 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
},
|
||||
// First CreateDocuments result
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_create_a".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1572,6 +1708,7 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
},
|
||||
// Agent output before second plan
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_text_2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1586,6 +1723,7 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
},
|
||||
// Second CreateDocuments tool call
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_create_b".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1608,6 +1746,7 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
},
|
||||
// Second CreateDocuments result
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_create_b".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1694,7 +1833,6 @@ fn test_multiple_create_documents_get_default_version() {
|
||||
#[test]
|
||||
fn test_create_then_edit_then_create_version_tracking() {
|
||||
use crate::ai::agent::{AIAgentActionResultType, CreateDocumentsResult, EditDocumentsResult};
|
||||
use crate::ai::document::ai_document_model::AIDocumentVersion;
|
||||
|
||||
let doc_id_a = uuid::Uuid::new_v4().to_string();
|
||||
let doc_id_b = uuid::Uuid::new_v4().to_string();
|
||||
@@ -1702,6 +1840,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
let messages = vec![
|
||||
// User query
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "user_msg".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1718,6 +1857,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Agent output
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_text".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1732,6 +1872,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Create doc A tool call
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_create_a".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1754,6 +1895,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Create doc A result
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_create_a".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1782,6 +1924,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Agent output before edit
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_text_2".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1796,6 +1939,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Edit doc A tool call
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_edit_a".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1817,6 +1961,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Edit doc A result
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_edit_a".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1845,6 +1990,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Agent output before second create
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "agent_text_3".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1859,6 +2005,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Create doc B tool call
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "tool_call_create_b".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1881,6 +2028,7 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
},
|
||||
// Create doc B result
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "result_create_b".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
@@ -1979,3 +2127,74 @@ fn test_create_then_edit_then_create_version_tracking() {
|
||||
"Created doc B should have default version (v1), independent of doc A"
|
||||
);
|
||||
}
|
||||
|
||||
/// Verify that a `SystemQuery::HandoffRehydration` message does not produce
|
||||
/// a displayed input when restoring a conversation. It must be treated as
|
||||
/// hidden, so the exchange should have zero user-visible inputs.
|
||||
#[test]
|
||||
fn test_handoff_rehydration_system_query_is_hidden() {
|
||||
let messages = vec![
|
||||
// HandoffRehydration system query – should be hidden
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "msg_handoff".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
citations: vec![],
|
||||
message: Some(api::message::Message::SystemQuery(
|
||||
api::message::SystemQuery {
|
||||
r#type: Some(api::message::system_query::Type::HandoffRehydration(
|
||||
api::message::HandoffRehydration {
|
||||
instructions: "restore handoff state".to_string(),
|
||||
},
|
||||
)),
|
||||
context: None,
|
||||
},
|
||||
)),
|
||||
request_id: "req1".to_string(),
|
||||
timestamp: None,
|
||||
},
|
||||
// Agent output that follows the hidden system query
|
||||
api::Message {
|
||||
fetched_memories: vec![],
|
||||
id: "msg_output".to_string(),
|
||||
task_id: "task1".to_string(),
|
||||
server_message_data: "".to_string(),
|
||||
citations: vec![],
|
||||
message: Some(api::message::Message::AgentOutput(
|
||||
api::message::AgentOutput {
|
||||
text: "I have restored the handoff state.".to_string(),
|
||||
},
|
||||
)),
|
||||
request_id: "req1".to_string(),
|
||||
timestamp: None,
|
||||
},
|
||||
];
|
||||
|
||||
let task = api::Task {
|
||||
id: "task1".to_string(),
|
||||
messages,
|
||||
dependencies: None,
|
||||
description: "".to_string(),
|
||||
summary: "".to_string(),
|
||||
server_data: "".to_string(),
|
||||
};
|
||||
|
||||
let exchanges = task.into_exchanges();
|
||||
assert_eq!(exchanges.len(), 1, "Should produce exactly one exchange");
|
||||
|
||||
let exchange = &exchanges[0];
|
||||
// The HandoffRehydration should NOT appear as input
|
||||
assert!(
|
||||
exchange.input.is_empty(),
|
||||
"HandoffRehydration must not produce a displayed input, got: {:?}",
|
||||
exchange.input
|
||||
);
|
||||
|
||||
// The agent output should still be present
|
||||
let output = exchange.output_status.output().expect("should have output");
|
||||
assert!(
|
||||
!output.get().messages.is_empty(),
|
||||
"Agent output should still be rendered"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user