mirror of
https://github.com/openai/codex.git
synced 2026-11-21 07:09:23 +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
@@ -3,7 +3,6 @@ use codex_api::ImageEditRequest;
|
||||
use codex_api::ImageGenerationRequest;
|
||||
use codex_api::ImageQuality;
|
||||
use codex_api::ImageUrl;
|
||||
use codex_core::context::extension_image_generation_output_hint;
|
||||
use codex_extension_api::ToolOutput;
|
||||
use codex_extension_api::ToolPayload;
|
||||
use codex_extension_api::ToolSpec;
|
||||
@@ -16,6 +15,7 @@ use codex_protocol::models::FunctionCallOutputPayload;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_tools::ResponsesApiNamespaceTool;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::GeneratedImageOutput;
|
||||
@@ -25,9 +25,24 @@ use super::imagegen_tool_spec;
|
||||
use super::request_for_call_args;
|
||||
use crate::IMAGE_GEN_NAMESPACE;
|
||||
use crate::IMAGEGEN_TOOL_NAME;
|
||||
use crate::artifact::image_generation_artifact_path;
|
||||
use crate::artifact::image_generation_output_hint;
|
||||
|
||||
const RESULT: &str = "cG5n";
|
||||
|
||||
#[test]
|
||||
fn artifact_path_sanitizes_session_and_call_ids() {
|
||||
let save_root = AbsolutePathBuf::current_dir().expect("current directory should be absolute");
|
||||
|
||||
assert_eq!(
|
||||
image_generation_artifact_path(&save_root, "../session", "../call"),
|
||||
save_root
|
||||
.join("generated_images")
|
||||
.join("___session")
|
||||
.join("___call.png")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uses_reserved_image_gen_namespace() {
|
||||
let ToolSpec::Namespace(spec) = imagegen_tool_spec() else {
|
||||
@@ -224,7 +239,7 @@ async fn recent_image_fallback_requires_requested_count() {
|
||||
#[test]
|
||||
fn generated_output_returns_image_input_and_output_hint() {
|
||||
let output_hint =
|
||||
extension_image_generation_output_hint("/tmp", "/tmp/call-1.png").expect("hint should fit");
|
||||
image_generation_output_hint("/tmp", "/tmp/call-1.png").expect("hint should fit");
|
||||
let output = GeneratedImageOutput {
|
||||
result: RESULT.to_string(),
|
||||
output_hint: Some(output_hint.clone()),
|
||||
@@ -273,7 +288,7 @@ fn generated_output_omits_oversized_output_hint() {
|
||||
let long_path = "x".repeat(1024);
|
||||
let output = GeneratedImageOutput {
|
||||
result: RESULT.to_string(),
|
||||
output_hint: extension_image_generation_output_hint("/tmp", long_path),
|
||||
output_hint: image_generation_output_hint("/tmp", long_path),
|
||||
};
|
||||
|
||||
let ResponseInputItem::FunctionCallOutput {
|
||||
|
||||
Reference in new issue
Block a user