Why typescript sdk outputSchema doesn't work

Open 💬 7 comments Opened Feb 2, 2026 by GRCmade
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

0.93.0

What subscription do you have?

p

Which model were you using?

gpt5.2

What platform is your computer?

mac

What terminal emulator and version are you using (if applicable)?

terminal

What issue are you seeing?

I tried running the script below, but the result was not the expected JSON-formatted structured text; instead, it was plain text.

import { Codex } from "@openai/codex-sdk";

const codex = new Codex();
const thread = codex.startThread();
const schema = {
  type: "object",
  properties: {
    summary: { type: "string" },
    status: { type: "string", enum: ["ok", "action_required"] },
  },
  required: ["summary", "status"],
  additionalProperties: false,
}

const turn = await thread.run("hello", { outputSchema: schema });
console.log(turn);

the result
➜ codex-exec-demo git:(main) ✗ node demo.mjs
{
items: [
{
id: 'item_0',
type: 'agent_message',
text: 'Hi! What can I help you with?'
}
],
finalResponse: 'Hi! What can I help you with?',
usage: { input_tokens: 11134, cached_input_tokens: 6656, output_tokens: 33 }
}

What steps can reproduce the bug?

run this script

What is the expected behavior?

I need to output structured content

Additional information

_No response_

View original on GitHub ↗

7 Comments

etraut-openai contributor · 5 months ago

Thanks for the report. I wasn't able to reproduce the problem using your script. Here's what I received as an output.

{
  "items": [
    {
      "id": "item_1",
      "type": "agent_message",
      "text": "{\"summary\":\"Hey! 👋 What would you like to work on in the TypeScript SDK today?\",\"status\":\"ok\"}"
    }
  ],
  "finalResponse": "{\"summary\":\"Hey! 👋 What would you like to work on in the TypeScript SDK today?\",\"status\":\"ok\"}",
  "usage": {
    "input_tokens": 17221,
    "cached_input_tokens": 3584,
    "output_tokens": 36
  }
}

Are you consistently seeing this problem, or was it a one-time issue?

Are you sure you are using the latest published SDK?

GRCmade · 5 months ago
Thanks for the report. I wasn't able to reproduce the problem using your script. Here's what I received as an output. { "items": [ { "id": "item_1", "type": "agent_message", "text": "{\"summary\":\"Hey! 👋 What would you like to work on in the TypeScript SDK today?\",\"status\":\"ok\"}" } ], "finalResponse": "{\"summary\":\"Hey! 👋 What would you like to work on in the TypeScript SDK today?\",\"status\":\"ok\"}", "usage": { "input_tokens": 17221, "cached_input_tokens": 3584, "output_tokens": 36 } } Are you consistently seeing this problem, or was it a one-time issue? Are you sure you are using the latest published SDK?

Thank you for your reply. I do have an issue here; even the CLI is like this. I'm not very sure where the problem is coming from.

How should I troubleshoot it?

➜  codex-exec-demo git:(main) ✗ codex --version
codex-cli 0.93.0
➜  codex-exec-demo git:(main) ✗ codex exec hello --output-schema codex-schema.json 
OpenAI Codex v0.93.0 (research preview)
--------
workdir: /Users/gaoruicheng/Desktop/codex-exec-demo
model: gpt-5.2-codex
provider: right
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: auto
session id: 019c1f82-93f5-72b2-ae5a-46a9bde8470e
--------
user
hello
mcp startup: no servers

thinking
**Adding greeting logic**
codex
Hey! What can I do for you?
tokens used
902
Hey! What can I do for you?
➜  codex-exec-demo git:(main) ✗ 

this is my demo

codex-exec-demo.zip

etraut-openai contributor · 5 months ago

Do you have any non-default config settings defined in your ~/.codex/config.toml config file?

GRCmade · 5 months ago
Do you have any non-default config settings defined in your ~/.codex/config.toml config file?

This is my ~/.codex/config.toml. Is there anything that could affect outputSchema?

config.toml.zip

etraut-openai contributor · 5 months ago

You appear to be routing through a proxy of some sort (https://right.codes/codex/v1). I'm guessing that it's not passing along the outputSchema. Try disabling the proxy and directly accessing the OpenAI endpoint to see if that works.

GRCmade · 5 months ago
You appear to be routing through a proxy of some sort (https://right.codes/codex/v1). I'm guessing that it's not passing along the outputSchema. Try disabling the proxy and directly accessing the OpenAI endpoint to see if that works.

Okay, thanks again for your feedback. I'll check it.

zy445566 · 3 months ago
Okay, thanks again for your feedback. I'll check it.

Did you solve that?I have this question too,these's my code:

import { Codex } from "@openai/codex-sdk";

const codex = new Codex();
const thread = codex.startThread({skipGitRepoCheck: true});
const schema = {
  type: "object",
  properties: {
    message: { type: "string" }
  },
  required: ["message"],
  additionalProperties: false,
};

const turn = await thread.run("你好", { outputSchema: schema });
console.log(turn);