chore: clamp min yield time for empty write_stdin (#9156)
After evals, 0 impact on performance
This commit is contained in:
parent
bdae0035ec
commit
32b1795ff4
3 changed files with 16 additions and 5 deletions
|
|
@ -45,6 +45,8 @@ pub(crate) use errors::UnifiedExecError;
|
|||
pub(crate) use process::UnifiedExecProcess;
|
||||
|
||||
pub(crate) const MIN_YIELD_TIME_MS: u64 = 250;
|
||||
// Minimum yield time for an empty `write_stdin`.
|
||||
pub(crate) const MIN_EMPTY_YIELD_TIME_MS: u64 = 5_000;
|
||||
pub(crate) const MAX_YIELD_TIME_MS: u64 = 30_000;
|
||||
pub(crate) const DEFAULT_MAX_OUTPUT_TOKENS: usize = 10_000;
|
||||
pub(crate) const UNIFIED_EXEC_OUTPUT_MAX_BYTES: usize = 1024 * 1024; // 1 MiB
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ use crate::truncate::approx_token_count;
|
|||
use crate::truncate::formatted_truncate_text;
|
||||
use crate::unified_exec::ExecCommandRequest;
|
||||
use crate::unified_exec::MAX_UNIFIED_EXEC_PROCESSES;
|
||||
use crate::unified_exec::MAX_YIELD_TIME_MS;
|
||||
use crate::unified_exec::MIN_EMPTY_YIELD_TIME_MS;
|
||||
use crate::unified_exec::ProcessEntry;
|
||||
use crate::unified_exec::ProcessStore;
|
||||
use crate::unified_exec::UnifiedExecContext;
|
||||
|
|
@ -263,7 +265,14 @@ impl UnifiedExecProcessManager {
|
|||
}
|
||||
|
||||
let max_tokens = resolve_max_tokens(request.max_output_tokens);
|
||||
let yield_time_ms = clamp_yield_time(request.yield_time_ms);
|
||||
let yield_time_ms = {
|
||||
let time_ms = clamp_yield_time(request.yield_time_ms);
|
||||
if request.input.is_empty() {
|
||||
time_ms.clamp(MIN_EMPTY_YIELD_TIME_MS, MAX_YIELD_TIME_MS)
|
||||
} else {
|
||||
time_ms
|
||||
}
|
||||
};
|
||||
let start = Instant::now();
|
||||
let deadline = start + Duration::from_millis(yield_time_ms);
|
||||
let collected = Self::collect_output_until_deadline(
|
||||
|
|
|
|||
|
|
@ -902,21 +902,21 @@ async fn unified_exec_terminal_interaction_captures_delayed_output() -> Result<(
|
|||
// and a final long poll to capture the second marker.
|
||||
let first_poll_call_id = "uexec-delayed-poll-1";
|
||||
let first_poll_args = json!({
|
||||
"chars": "",
|
||||
"chars": "x",
|
||||
"session_id": 1000,
|
||||
"yield_time_ms": 10,
|
||||
});
|
||||
|
||||
let second_poll_call_id = "uexec-delayed-poll-2";
|
||||
let second_poll_args = json!({
|
||||
"chars": "",
|
||||
"chars": "x",
|
||||
"session_id": 1000,
|
||||
"yield_time_ms": 4000,
|
||||
});
|
||||
|
||||
let third_poll_call_id = "uexec-delayed-poll-3";
|
||||
let third_poll_args = json!({
|
||||
"chars": "",
|
||||
"chars": "x",
|
||||
"session_id": 1000,
|
||||
"yield_time_ms": 6000,
|
||||
});
|
||||
|
|
@ -1037,7 +1037,7 @@ async fn unified_exec_terminal_interaction_captures_delayed_output() -> Result<(
|
|||
.iter()
|
||||
.map(|ev| ev.stdin.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["", "", ""],
|
||||
vec!["x", "x", "x"],
|
||||
"terminal interactions should reflect the three stdin polls"
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue