@@ -161,12 +161,15 @@ protected function addStep(
161161 ClientResponse $ clientResponse ,
162162 array $ toolResults = []
163163 ): void {
164+ /** @var array<array-key, array<string, mixed>> $output */
165+ $ output = data_get ($ data , 'output ' , []);
166+
164167 $ this ->responseBuilder ->addStep (new Step (
165168 text: data_get ($ data , 'output.{last}.content.0.text ' ) ?? '' ,
166169 finishReason: $ this ->mapFinishReason ($ data ),
167- toolCalls: ToolCallMap::map (array_filter (data_get ( $ data , ' output ' , []) , fn (array $ output ): bool => $ output ['type ' ] === 'function_call ' )),
170+ toolCalls: ToolCallMap::map (array_filter ($ output , fn (array $ output ): bool => $ output ['type ' ] === 'function_call ' )),
168171 toolResults: $ toolResults ,
169- providerToolCalls: ProviderToolCallMap::map (data_get ( $ data , ' output ' , []) ),
172+ providerToolCalls: ProviderToolCallMap::map ($ output ),
170173 usage: new Usage (
171174 promptTokens: data_get ($ data , 'usage.input_tokens ' , 0 ) - data_get ($ data , 'usage.input_tokens_details.cached_tokens ' , 0 ),
172175 completionTokens: data_get ($ data , 'usage.output_tokens ' ),
@@ -183,6 +186,11 @@ protected function addStep(
183186 systemPrompts: $ request ->systemPrompts (),
184187 additionalContent: Arr::whereNotNull ([
185188 'citations ' => $ this ->citations ,
189+ 'reasoningSummaries ' => collect ($ output )
190+ ->filter (fn (array $ output ): bool => $ output ['type ' ] === 'reasoning ' )
191+ ->flatMap (fn (array $ output ): array => Arr::pluck ($ output ['summary ' ] ?? [], 'text ' ))
192+ ->filter ()
193+ ->toArray (),
186194 ]),
187195 ));
188196 }
0 commit comments