Structured output
Is it possible to use structured output similar to Codex SDK? https://github.com/openai/codex/blob/main/sdk/typescript/samples/structured_output.ts
Thanks for suggesting this, @MLgentDev. Seems like a very reasonable feature request.
@SteveSandersonMS
I saw we're sending a json in this format to copilot-server:
{
"jsonrpc": "2.0",
"id": "b3f4e56a-4fee-4ace-afee-961d47e377bd",
"method": "session.send",
"params": {
"sessionId": "a008569d-2eeb-47de-8bd6-db39f19ec72c",
"prompt": "What\'s the weather in Seattle and Tokyo?",
"attachments": null,
"mode": null
}
}
Is there a field like json_schema that we can put into this request to force return a json like what we have in openai client?
@JC1DA No, currently not. This issue tracks that feature request.
+1 on this feature request, thanks.
+1 Will make it A LOT better to be integrated in workflows and/or handoff scenarios.
This is a need where i am to implement this into proper production workflows. Please implement
+1 for this feature
@SteveSandersonMS any update on this?
It seems the feature has been merged, no?
Has anyone used this with python sdk?
Where does this exist in any sdk? I am not able to see anything afaik
Thanks, everyone, for your patience. Typed structured output shipped for all six SDKs in Copilot SDK v1.0.15 (#2590): in TypeScript, pass a schema as the second argument, for example await session.sendAndWait("What is 19 + 23?", answerSchema), or a raw JSON Schema via responseSchema in the message options, and in Python use await session.send_and_wait_typed(prompt, MyModel) with a Pydantic model. Go, Java, .NET and Rust have the equivalent copilot.SendAndWait[T], session.sendAndWait(prompt, T.class), SendAndWaitAsync<T> and send_and_wait_typed. The schema applies per message and the result is validated before it's returned. If you run into problems on the latest version, please open a new issue or reopen this one.
Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.