mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
## Summary - honor `_meta["codex/imageDetail"] == "original"` on MCP image content and map it to `detail: "original"` where supported - strip that detail back out when the active model does not support original-detail image inputs - update code-mode `image(...)` to accept individual MCP image blocks - teach `js_repl` / `codex.emitImage(...)` to preserve the same hint from raw MCP image outputs - document the new `_meta` contract and add generic RMCP-backed coverage across protocol, core, code-mode, and js_repl paths
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use codex_protocol::models::FunctionCallOutputContentItem;
|
|
use codex_protocol::models::ImageDetail;
|
|
use codex_protocol::openai_models::ModelInfo;
|
|
|
|
pub fn can_request_original_image_detail(model_info: &ModelInfo) -> bool {
|
|
model_info.supports_image_detail_original
|
|
}
|
|
|
|
pub fn normalize_output_image_detail(
|
|
model_info: &ModelInfo,
|
|
detail: Option<ImageDetail>,
|
|
) -> Option<ImageDetail> {
|
|
match detail {
|
|
Some(ImageDetail::Original) if can_request_original_image_detail(model_info) => {
|
|
Some(ImageDetail::Original)
|
|
}
|
|
Some(ImageDetail::Original) | Some(_) | None => None,
|
|
}
|
|
}
|
|
|
|
pub fn sanitize_original_image_detail(
|
|
can_request_original_image_detail: bool,
|
|
items: &mut [FunctionCallOutputContentItem],
|
|
) {
|
|
if can_request_original_image_detail {
|
|
return;
|
|
}
|
|
|
|
for item in items {
|
|
if let FunctionCallOutputContentItem::InputImage { detail, .. } = item
|
|
&& matches!(detail, Some(ImageDetail::Original))
|
|
{
|
|
*detail = None;
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "image_detail_tests.rs"]
|
|
mod tests;
|