mirror of
https://github.com/openai/codex.git
synced 2026-11-13 21:30:47 +00:00
Add a content helper for forwarding MCP blocks in Code Mode (#60665)
## Why Code Mode needs a way to forward mixed MCP tool results while preserving their content types and order. ## What changed Add `content(block)` and `content(iterable)` so callers can forward tool output with `content(result.content)`. Text, image, and audio blocks become their corresponding output items; resource links and embedded resources are serialized as text. Invalid blocks and encrypted text are rejected, and iterators are closed when a block is rejected. Share MCP block conversion and image detail types with the protocol layer, while preserving existing `image()` and `audio()` input handling. ## Testing Add coverage for mixed content ordering, iterator behavior and cleanup, invalid blocks, image metadata, short audio clips, and output suppression after exit. Add an integration scenario verifying that MCP text and image blocks reach the model in order. GitOrigin-RevId: 83832ec6c530dd35ea1e3373680627997c6e13c1
This commit is contained in:
committed by
copyberry
parent
f7aad26f1d
commit
733a1cca06
@@ -41,6 +41,7 @@ async fn host_callbacks_admit_no_new_effects_after_exit_is_requested() {
|
||||
r#"
|
||||
markExit();
|
||||
text("still working");
|
||||
content({type: "text", text: "late"});
|
||||
image("data:image/png;base64,AAA");
|
||||
audio("data:audio/mpeg;base64,YXVkaW8=");
|
||||
generatedImage({image_url: "data:image/png;base64,AAA", output_hint: "late"});
|
||||
@@ -53,6 +54,14 @@ clearTimeout(earlyTimer); setTimeout(() => {}, 60000);
|
||||
"text conversion",
|
||||
r#"text({toJSON() { return markExit("late"); }});"#,
|
||||
),
|
||||
(
|
||||
"content getter",
|
||||
r#"content({type: "text", get text() { return markExit("late"); }});"#,
|
||||
),
|
||||
(
|
||||
"content iterator",
|
||||
r#"content((function* () { yield markExit({type: "text", text: "late"}); })());"#,
|
||||
),
|
||||
(
|
||||
"notify conversion",
|
||||
r#"notify({toJSON() { return markExit("late"); }});"#,
|
||||
|
||||
Reference in New Issue
Block a user