Hmbown/CodeWhale · error
stdin is not available for task
Error message
stdin is not available for task {} What it means
The shell task's stdin writer refuses input when no stdin channel is available for the task. If the caller sent an empty input without requesting close, the method returns Ok early; in every other case where stdin cannot be delivered (the task has no live stdin handle, e.g. it already exited or was spawned with stdin closed), it throws "stdin is not available for task {id}".
Solutions
- Confirm the task was spawned with an interactive stdin pipe (the mode that exposes stdin) before sending input.
- Check the task's status first — if it has exited, stdin is gone; start a new task instead.
- If you only wanted to signal completion, send an empty input with close=true only when stdin exists, otherwise handle the already-terminated case gracefully.
Example fix
// before
if task.status() == Exited {
task.send_input("y\n", false)?; // errors: stdin gone
}
// after
if task.supports_stdin() && task.status() != Exited {
task.send_input("y\n", false)?;
} else {
return Err(anyhow!("task {} cannot accept stdin", task.id()));
} Defensive patterns
Strategy: type-guard
Type guard
fn can_send_stdin(task: &ShellTask) -> bool {
task.supports_stdin() && !task.has_exited()
}
// guard before writing:
// if can_send_stdin(&task) { task.send_input(data, close)?; } Try / catch
// treat this as a state error: do not retry blindly
match task.send_input(input, close) {
Ok(()) => {}
Err(e) if e.to_string().contains("stdin is not available") => {
// task not interactive or already exited: surface or start a new task
}
Err(e) => return Err(e),
} Prevention
- Only spawn interactive tasks when you intend to write to stdin.
- Check task status for exit before sending input.
- Combine empty input with close=true only when stdin is known to exist.
When it happens
Trigger: Calling the shell task's write-input/send-stdin method with non-empty input (or close=true with input) on a task that was not spawned with an interactive stdin pipe, or whose process has already exited and dropped its stdin handle.
Common situations: Attempting to interactively prompt a long-running command that was launched without stdin attached; sending input to a task after it finished; tools/clients treating every shell job as interactive when only some are spawned with pipes.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Failed to write review payload
- shell command failed
- Agent has no continuable checkpoint to resume from…
- agent profile may not request allow_shell=true
- allowlisted read-only executable
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/cb857acf9ce39536.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/shell.rs:1367
}
fn write_stdin_bytes(&mut self, input: &[u8], close: bool) -> Result<()> {
if let Some(stdin) = self.stdin.as_mut() {
if !input.is_empty() {
stdin.write_all(input).context("Failed to write to stdin")?;
stdin.flush().context("Failed to flush stdin")?;
}
if close {
self.stdin = None;
}
return Ok(());
}
if input.is_empty() && close {
return Ok(());
}
Err(anyhow!("stdin is not available for task {}", self.id))
}
fn full_output(&self) -> (String, String, usize, usize) {
if let Some(snapshot) = self.bounded_output_snapshot(false).ok().flatten() {
return (snapshot.content, String::new(), snapshot.total_bytes, 0);
}
let (stdout_bytes, stderr_bytes, stdout_omitted, stderr_omitted) =
self.retained_output_bytes_with_omissions();
// Report what the stream produced, not what is still held.
let stdout_len = stdout_bytes.len().saturating_add(stdout_omitted);
let stderr_len = stderr_bytes.len().saturating_add(stderr_omitted);
(
String::from_utf8_lossy(&stdout_bytes).to_string(),
String::from_utf8_lossy(&stderr_bytes).to_string(),
stdout_len,
stderr_len,
)View on GitHub (pinned to 73e0f67d83)