openai/codex · warning · io::Error
generated image destination already exists
Error message
generated image destination already exists
What it means
Immediately before writing, save_image_generation_result stats the destination (derived from session_id and call_id): any successful stat returns AlreadyExists. Only NotFound proceeds — an existing destination (e.g. a hardlink) could otherwise overwrite files outside the workspace, so overwriting is never attempted.
Source
Thrown at codex-rs/ext/image-generation/src/tool.rs:361
.get_metadata(&parent_uri, Default::default(), sandbox)
.await?;
if metadata.is_symlink || !metadata.is_directory {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
"generated image directory is not a real directory",
));
}
}
// Existing destination hardlinks could otherwise overwrite files outside the workspace.
let path_uri = PathUri::from_abs_path(&path);
match environment
.file_system
.get_metadata(&path_uri, Default::default(), sandbox)
.await
{
Ok(_) => {
return Err(io::Error::new(
io::ErrorKind::AlreadyExists,
"generated image destination already exists",
));
}
Err(error) if error.kind() == io::ErrorKind::NotFound => {}
Err(error) => return Err(error),
}
environment
.file_system
.write_file(&path_uri, bytes, Default::default(), sandbox)
.await?;
Ok(path)
}
.await;
(output_dir, save_result)
}
};View on GitHub (pinned to 339751715c)
Solutions
- Generate a fresh call_id when retrying the image tool call.
- Delete the stale artifact named in the warning if the run is genuinely new.
- Treat as informational: the model still receives the generated image; only persistence is skipped.
Defensive patterns
Strategy: validation
Validate before calling
// Before replaying a tool call, ensure the artifact name is free
if artifact_path.exists() {
std::fs::remove_file(&artifact_path)?; // or mint a fresh call_id
} Prevention
- Mint a new call_id on every retry so destination names never collide.
- Clean generated_images between unrelated runs in shared workspaces.
- Treat AlreadyExists on replay as benign — persistence is skipped, the result is unaffected.
When it happens
Trigger: The same image tool call is retried or replayed with the same session_id and call_id, or a file already exists at generated_images/<artifact-name>.
Common situations: Client retry of a timed-out tool call reusing the call id; two executions sharing a session id; leftover artifacts from a previous run.
Related errors
- generated image exceeds the executor file size limit
- generated image directory is not a real directory
- pid-managed app-server shutdown is unsupported on this platf
- pid-managed updater shutdown is unsupported on this platform
- failed to read start time for pid-managed app server {pid}
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/37b9505fe15d3b13.
Report an issue: GitHub.