'assistant', 'content' => [ ['type' => 'text', 'text' => 'Checking weather.'], ['type' => 'tool_use', 'id' => 'call-1', 'name' => 'weather', 'input' => ['city' => 'Paris']], ], 'model' => 'test-model', 'stopReason' => 'toolUse', '_meta' => ['traceId' => 'trace-1'], ]); $this->assertInstanceOf(TextContent::class, $result->content[0]); $this->assertInstanceOf(ToolUseContent::class, $result->content[1]); $this->assertSame('toolUse', $result->stopReason); $this->assertSame('toolUse', $result->jsonSerialize()['stopReason']); $this->assertSame(['traceId' => 'trace-1'], $result->jsonSerialize()['_meta']); } public function testProviderSpecificStopReasonIsPreserved(): void { $result = CreateSamplingMessageResult::fromArray([ 'role' => 'assistant', 'content' => ['type' => 'text', 'text' => 'Done'], 'model' => 'test-model', 'stopReason' => 'provider-specific', ]); $this->assertSame('provider-specific', $result->stopReason); $this->assertSame('provider-specific', $result->jsonSerialize()['stopReason']); } }