Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions aisdk/ai/provider/openai/internal/codec/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ func decodeReasoning(item responses.ResponseOutputItemUnion) (*api.ReasoningBloc
}

reasoningItem := item.AsReasoning()
if len(reasoningItem.Summary) == 0 {
return nil, fmt.Errorf("reasoning item has no summary")
}

// For now, we'll concatenate all summary texts with newlines if there are multiple
// Another option would be to return a slice of ReasoningBlocks.
Expand All @@ -125,9 +122,9 @@ func decodeReasoning(item responses.ResponseOutputItemUnion) (*api.ReasoningBloc
texts = append(texts, summary.Text)
}

if len(texts) == 0 {
return nil, fmt.Errorf("no valid text found in reasoning summaries")
}
// NOTE: we don't check that the text is non-empty because sometimes the model returns an empty
// reasoning block. That behavior is technically against the API spec, but it's been observed in practice.
// Consider omitting the ReasoningBlock and adding a warning instead.

return &api.ReasoningBlock{
Text: strings.Join(texts, "\n"),
Expand Down
2 changes: 1 addition & 1 deletion aisdk/ai/provider/openai/internal/codec/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ func TestDecodeReasoning(t *testing.T) {
"id": "reason_123",
"summary": []
}`,
wantErr: "reasoning item has no summary",
want: &api.ReasoningBlock{},
},
{
name: "empty text in summary",
Expand Down
Loading