Skip to content

Add code_mode output helpers for text and images#14244

Merged
pakrym-oai merged 4 commits intomainfrom
pakrym/fetch-main-branch-updates
Mar 10, 2026
Merged

Add code_mode output helpers for text and images#14244
pakrym-oai merged 4 commits intomainfrom
pakrym/fetch-main-branch-updates

Conversation

@pakrym-oai
Copy link
Collaborator

Summary

  • document how code-mode can import output_text/output_image and ensure add_content stays compatible
  • add a synthetic @openai/code_mode module that appends content items and validates inputs
  • cover the new behavior with integration tests for structured text and image outputs

Testing

  • Not run (not requested)

Copy link
Contributor

@cconger cconger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonblocking questions inline.

if (typeof serialized === 'string') {
return serialized;
}
} catch {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a mechanism by which we plan on surfacing errors. I feel like showing the model that there was a serialization error would be helpful here.

I see we have the typeerror below for image strings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good idea we should just let this bubble up.

function createCodeModeModule(context) {
const outputText = (value) => {
const item = {
type: 'input_text',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these keyed "input_*"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image https://developers.openai.com/api/reference/resources/responses/

serde_json::json!({
"type": "custom_tool_call_output",
"call_id": "call-1",
"output": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it important for output to be so structured here instead of freeform?

I feel like we might also want to provide some kind of typedArray uint8 to allow byte passing in and out instead of requiring data:base64 encoding if we want to allow the model to output image data as "I want to see this" payload.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it important for output to be so structured here instead of freeform?

That's the content_item format from Responses API. That's how it distinguishes images that the model wants to see from raw text.

@pakrym-oai pakrym-oai enabled auto-merge (squash) March 10, 2026 21:51
@pakrym-oai pakrym-oai disabled auto-merge March 10, 2026 23:25
@pakrym-oai pakrym-oai merged commit 8b33485 into main Mar 10, 2026
30 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/fetch-main-branch-updates branch March 10, 2026 23:25
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants