copilot-sdk icon indicating copy to clipboard operation
copilot-sdk copied to clipboard

Structured output

Open MLgentDev opened this issue 10 months ago • 12 comments

Is it possible to use structured output similar to Codex SDK? https://github.com/openai/codex/blob/main/sdk/typescript/samples/structured_output.ts

MLgentDev avatar Jan 17 '26 17:01 MLgentDev

Thanks for suggesting this, @MLgentDev. Seems like a very reasonable feature request.

SteveSandersonMS avatar Jan 19 '26 14:01 SteveSandersonMS

@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 avatar Jan 26 '26 23:01 JC1DA

@JC1DA No, currently not. This issue tracks that feature request.

SteveSandersonMS avatar Jan 27 '26 09:01 SteveSandersonMS

+1 on this feature request, thanks.

moonbox3 avatar Mar 19 '26 03:03 moonbox3

+1 Will make it A LOT better to be integrated in workflows and/or handoff scenarios.

ghost avatar Mar 23 '26 09:03 ghost

This is a need where i am to implement this into proper production workflows. Please implement

vz443 avatar May 04 '26 03:05 vz443

+1 for this feature

droideronline avatar Jun 22 '26 11:06 droideronline

@SteveSandersonMS any update on this?

vz443 avatar Jul 30 '26 01:07 vz443

It seems the feature has been merged, no?

michal-gora avatar Aug 06 '26 14:08 michal-gora

Has anyone used this with python sdk?

Matheus-Garbelini avatar Aug 06 '26 15:08 Matheus-Garbelini

Where does this exist in any sdk? I am not able to see anything afaik

vz443 avatar Aug 10 '26 05:08 vz443

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.

patniko avatar Oct 26 '26 20:10 patniko