Skip to content

Commit c1074e0

Browse files
From<OutputItem> for Item (and InputItem) for multi-turn responses (#538)
* Add From<OutputItem> for Item / InputItem (multi-turn responses) The Responses API requires Reasoning items to be echoed back into the next request's input alongside the FunctionCall items they preceded. Without that pairing the server rejects the request with: Item 'fc_...' of type 'function_call' was provided without its required 'reasoning' item: 'rs_...' In the Python and Node SDKs the canonical pattern is `input_list += response.output` because their input/output item types are the same. In Rust the schemas split into Item vs OutputItem, with several variants that have *Resource (output, required id/status) and *ItemParam (input, optional id/status) flavors, so callers had to hand-write a per-variant conversion to do what's a one-liner in the official SDKs. Add From<OutputItem> for Item and From<OutputItem> for InputItem, plus the supporting per-variant From impls (status enum mappings, shell environment/outcome mappings, apply_patch operation mappings, resource-to-param mappings). Required id/status fields fold into Some(...) on the way in; the output-only created_by annotation is dropped because the input schema doesn't accept it. The canonical SDK pattern now works: input_items.extend(response.output.into_iter().map(InputItem::from)); Includes round-trip tests covering the headline reasoning + function_call pairing case plus the resource-to-param folding for ApplyPatch, Compaction, and FunctionCallOutput. New responses-multi-turn-reasoning example demonstrates the pattern with a reasoning model. Closes #492. * chore: fmt
1 parent 5fba89d commit c1074e0

4 files changed

Lines changed: 671 additions & 14 deletions

File tree

0 commit comments

Comments
 (0)