mirror of
https://github.com/openai/codex.git
synced 2026-11-04 08:25:29 +00:00
Avoid rendering generated images twice (#34378)
## What changed - Tell the model that generated images are already displayed to the user and should not be repeated as Markdown images or file links. - Keep generated-image artifact paths and output hints owned by the image generation extension. - Centralize the availability check for the image generation tool across feature, provider, namespace-tool, model modality, and authentication requirements. ## Testing - Verify artifact paths sanitize session and call identifiers. - Verify the model-facing output hint reports that the generated image is already displayed. GitOrigin-RevId: 6c865b6a96d6a71bb2c33246d1518a00e7c8b840
This commit is contained in:
1 parent
9a7e823e5b
commit
7e51abbbd1
12 files changed
+99
-95
No files matched your search
@@ -25,44 +25,12 @@ use codex_protocol::models::MessagePhase;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_rollout::state_db;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_stream_parser::strip_proposed_plan_blocks;
|
||||
use futures::Future;
|
||||
use tracing::debug;
|
||||
use tracing::instrument;
|
||||
use tracing::warn;
|
||||
|
||||
const GENERATED_IMAGE_ARTIFACTS_DIR: &str = "generated_images";
|
||||
|
||||
/// Returns the host-owned default artifact path for a generated image.
|
||||
pub fn image_generation_artifact_path(
|
||||
codex_home: &AbsolutePathBuf,
|
||||
session_id: &str,
|
||||
call_id: &str,
|
||||
) -> AbsolutePathBuf {
|
||||
let sanitize = |value: &str| {
|
||||
let mut sanitized: String = value
|
||||
.chars()
|
||||
.map(|ch| {
|
||||
if ch.is_ascii_alphanumeric() || ch == '-' || ch == '_' {
|
||||
ch
|
||||
} else {
|
||||
'_'
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if sanitized.is_empty() {
|
||||
sanitized = "generated_image".to_string();
|
||||
}
|
||||
sanitized
|
||||
};
|
||||
|
||||
codex_home
|
||||
.join(GENERATED_IMAGE_ARTIFACTS_DIR)
|
||||
.join(sanitize(session_id))
|
||||
.join(format!("{}.png", sanitize(call_id)))
|
||||
}
|
||||
|
||||
fn strip_hidden_assistant_markup(text: &str, plan_mode: bool) -> String {
|
||||
let (without_citations, _) = strip_citations(text);
|
||||
if plan_mode {
|
||||
|
||||
Reference in new issue
Block a user