File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -174,15 +174,12 @@ protected function ensureValidAlternation(): void
174
174
175
175
// Tool result messages have a special case - they're user messages
176
176
// but can only follow tool call messages (assistant)
177
- if ($ message instanceof ToolCallResultMessage) {
178
- // This is valid after a ToolCallMessage
179
- if (!empty ($ result ) &&
180
- $ result [\count ($ result ) - 1 ] instanceof ToolCallMessage) {
181
- $ result [] = $ message ;
182
- // After the tool result, we expect assistant again
183
- $ expectingRole = MessageRole::ASSISTANT ->value ;
184
- continue ;
185
- }
177
+ // This is valid after a ToolCallMessage
178
+ if ($ message instanceof ToolCallResultMessage && ($ result !== [] && $ result [\count ($ result ) - 1 ] instanceof ToolCallMessage)) {
179
+ $ result [] = $ message ;
180
+ // After the tool result, we expect assistant again
181
+ $ expectingRole = MessageRole::ASSISTANT ->value ;
182
+ continue ;
186
183
}
187
184
188
185
// Check if this message has the expected role
Original file line number Diff line number Diff line change @@ -184,15 +184,15 @@ public function test_remove_intermediate_invalid_message_types(): void
184
184
$ this ->chatHistory ->flushAll ();
185
185
}
186
186
187
- public function test_empty_history_if_no_user_message ()
187
+ public function test_empty_history_if_no_user_message (): void
188
188
{
189
189
$ this ->chatHistory ->flushAll ();
190
190
191
191
$ this ->chatHistory ->addMessage (new AssistantMessage ('Test message ' ));
192
192
$ this ->assertEmpty ($ this ->chatHistory ->getMessages ());
193
193
}
194
194
195
- public function test_remove_messages_before_the_first_user_message ()
195
+ public function test_remove_messages_before_the_first_user_message (): void
196
196
{
197
197
$ this ->chatHistory ->flushAll ();
198
198
You can’t perform that action at this time.
0 commit comments