35 lines
1.2 KiB
Rust
35 lines
1.2 KiB
Rust
use codex_protocol::AgentPath;
|
|
use codex_protocol::protocol::AgentStatus;
|
|
use codex_utils_output_truncation::approx_token_count;
|
|
|
|
use super::COMPLETION_MESSAGE_MAX_TOKENS;
|
|
use super::ERROR_NEXT_ACTION;
|
|
use super::GUARDIAN_NEXT_ACTION;
|
|
use super::format_guardian_interruption_message;
|
|
use super::format_inter_agent_completion_message;
|
|
|
|
#[test]
|
|
fn error_completion_message_stays_below_manual_review_threshold() {
|
|
let message = format_inter_agent_completion_message(
|
|
AgentPath::root(),
|
|
AgentPath::try_from("/root/worker").expect("valid agent path"),
|
|
&AgentStatus::Errored("stream disconnected ".repeat(1_000)),
|
|
)
|
|
.expect("error status should produce a completion message");
|
|
|
|
assert!(approx_token_count(&message) < COMPLETION_MESSAGE_MAX_TOKENS);
|
|
assert!(message.contains(ERROR_NEXT_ACTION));
|
|
}
|
|
|
|
#[test]
|
|
fn guardian_interruption_message_stays_below_manual_review_threshold() {
|
|
let message = format_guardian_interruption_message(
|
|
AgentPath::root(),
|
|
AgentPath::try_from("/root/worker").expect("valid agent path"),
|
|
&"Action is not authorized. ".repeat(1_000),
|
|
);
|
|
|
|
assert!(approx_token_count(&message) < COMPLETION_MESSAGE_MAX_TOKENS);
|
|
assert!(message.contains(GUARDIAN_NEXT_ACTION));
|
|
}
|