Skip to content

Commit a9f9e20

Browse files
committed
refactor(tui): extract subagent timeout values as named constants
1 parent ac6514b commit a9f9e20

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/cortex-tui/src/runner/event_loop/subagent.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
33
use std::time::{Duration, Instant};
44

5+
/// Connection timeout for subagent streaming requests.
6+
/// Higher than main streaming to allow for subagent initialization.
7+
const SUBAGENT_CONNECTION_TIMEOUT: Duration = Duration::from_secs(120);
8+
9+
/// Per-event timeout during subagent responses.
10+
/// Higher than main streaming to account for longer tool executions.
11+
const SUBAGENT_EVENT_TIMEOUT: Duration = Duration::from_secs(60);
12+
513
use crate::app::SubagentTaskDisplay;
614
use crate::events::{SubagentEvent, ToolEvent};
715
use crate::session::StoredToolCall;
@@ -210,7 +218,7 @@ impl EventLoop {
210218
};
211219

212220
let stream_result =
213-
tokio::time::timeout(Duration::from_secs(120), client.complete(request)).await;
221+
tokio::time::timeout(SUBAGENT_CONNECTION_TIMEOUT, client.complete(request)).await;
214222

215223
let mut stream = match stream_result {
216224
Ok(Ok(s)) => s,
@@ -252,7 +260,7 @@ impl EventLoop {
252260
let mut iteration_tool_calls: Vec<(String, String, serde_json::Value)> = Vec::new();
253261

254262
loop {
255-
let event = tokio::time::timeout(Duration::from_secs(60), stream.next()).await;
263+
let event = tokio::time::timeout(SUBAGENT_EVENT_TIMEOUT, stream.next()).await;
256264

257265
match event {
258266
Ok(Some(Ok(ResponseEvent::Delta(delta)))) => {

0 commit comments

Comments
 (0)