use crate::agent::instruction::{
InstructionDeliveryMode, normalize_instruction_conversation_id,
plan_app_server_instruction_delivery,
};
use crate::channel::AgentRequestKind;
#[test]
fn missing_conversation_ids_require_full_bootstrap() {
let ids = [None, Some(""), Some(" ")];
for current_id in ids {
let mode = plan_app_server_instruction_delivery(
&AgentRequestKind::SessionStart,
current_id,
None,
false,
);
assert_eq!(mode, InstructionDeliveryMode::BootstrapFull);
}
}
#[test]
fn test_plan_app_server_instruction_delivery_uses_delta_only_for_matching_state() {
let persisted_instruction_conversation_id =
normalize_instruction_conversation_id(Some("thread-123"));
let mode = plan_app_server_instruction_delivery(
&AgentRequestKind::SessionResume,
Some("thread-123"),
persisted_instruction_conversation_id.as_deref(),
false,
);
assert_eq!(mode, InstructionDeliveryMode::DeltaOnly);
}
#[test]
fn test_plan_app_server_instruction_delivery_uses_bootstrap_with_replay_after_reset() {
let persisted_instruction_conversation_id =
normalize_instruction_conversation_id(Some("thread-123"));
let mode = plan_app_server_instruction_delivery(
&AgentRequestKind::SessionResume,
Some("thread-456"),
persisted_instruction_conversation_id.as_deref(),
true,
);
assert_eq!(mode, InstructionDeliveryMode::BootstrapWithReplay);
}
#[test]
fn test_plan_app_server_instruction_delivery_bootstraps_full_for_new_context() {
let persisted_instruction_conversation_id =
normalize_instruction_conversation_id(Some("thread-123"));
let mode = plan_app_server_instruction_delivery(
&AgentRequestKind::SessionResume,
Some("thread-456"),
persisted_instruction_conversation_id.as_deref(),
false,
);
assert_eq!(mode, InstructionDeliveryMode::BootstrapFull);
}
#[test]
fn test_plan_app_server_instruction_delivery_bootstraps_full_for_utility_prompt() {
let persisted_instruction_conversation_id =
normalize_instruction_conversation_id(Some("thread-123"));
let mode = plan_app_server_instruction_delivery(
&AgentRequestKind::UtilityPrompt,
Some("thread-123"),
persisted_instruction_conversation_id.as_deref(),
false,
);
assert_eq!(mode, InstructionDeliveryMode::BootstrapFull);
}